diff --git a/lib/narn-lib.js b/lib/narn-lib.js index b145e1d..b9e67a4 100644 --- a/lib/narn-lib.js +++ b/lib/narn-lib.js @@ -40,7 +40,9 @@ exports.detectNpm = function detectNpm(args) { exports.getYarnArgs = narnArgs => narnArgs; exports.getNpmArgs = (narnArgs, isPnpm = false) => { - const yarnArgs = minimist(narnArgs, { boolean: ["dev", "D", "--latest"] }); + const yarnArgs = minimist(narnArgs, { + boolean: ["dev", "D", "latest", "frozen-lockfile"] + }); const yarnCommands = yarnArgs._; const yarnTarget = yarnCommands.length > 0 ? yarnCommands[0] : "install"; const yarnSubCommands = yarnCommands.slice(1); @@ -51,6 +53,13 @@ exports.getNpmArgs = (narnArgs, isPnpm = false) => { case "install": npmTarget = "install"; npmArgs = []; + if (yarnArgs["frozen-lockfile"]) { + if (isPnpm) { + npmArgs.push("--frozen-lockfile"); + } else { + npmTarget = "ci"; + } + } break; case "add": npmTarget = "install"; diff --git a/test/install.test.js b/test/install.test.js index d380f5d..a0b746c 100644 --- a/test/install.test.js +++ b/test/install.test.js @@ -8,4 +8,17 @@ describe("narn install", () => { it("works when install is specified", () => { expect(getNpmArgs(["install"])).toEqual(["install"]); }); + + describe("--frozen-lockfile", () => { + it("works with npm", () => { + expect(getNpmArgs(["install", "--frozen-lockfile"])).toEqual(["ci"]); + }); + + it("works with pnpm", () => { + expect(getNpmArgs(["install", "--frozen-lockfile"], true)).toEqual([ + "install", + "--frozen-lockfile" + ]); + }); + }); });