Skip to content

Commit 48fa66f

Browse files
hudochenkovMoOx
authored andcommitted
Use npm install if no lock files found (#25)
1 parent 89aa4f6 commit 48fa66f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

npmpub.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const error = msg => print(colors.red.bold(msg));
2323

2424
const cmds = {
2525
isYarn: "ls yarn.lock",
26+
isPackageLockPresent: "ls package-lock.json",
2627
install: undefined, // defined after isYarn test
2728
gitStatus: "git status --porcelain",
2829
gitFetch: "git fetch --quiet",
@@ -56,7 +57,22 @@ const isYarn = exec(cmds.isYarn, execOpts).code === 0;
5657
if (isYarn) {
5758
log("Yarn detected.");
5859
}
59-
cmds.install = isYarn ? "yarn --frozen-lockfile" : "npm ci";
60+
61+
// check if package-lock is used
62+
debug(cmds.isPackageLockPresent);
63+
const isPackageLockPresent =
64+
exec(cmds.isPackageLockPresent, execOpts).code === 0;
65+
if (isPackageLockPresent) {
66+
log("package-lock.json detected.");
67+
}
68+
69+
if (isYarn) {
70+
cmds.install = "yarn --frozen-lockfile";
71+
} else if (isPackageLockPresent) {
72+
cmds.install = "npm ci";
73+
} else {
74+
cmds.install = "npm install";
75+
}
6076

6177
// check clean status
6278
if (argv["skip-status"]) {

0 commit comments

Comments
 (0)