Skip to content

Commit

Permalink
Add support for --frozen-lockfile flag. Resolves #17
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Mar 14, 2020
1 parent 3d9d929 commit 0a14778
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/narn-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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";
Expand Down
13 changes: 13 additions & 0 deletions test/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]);
});
});
});

0 comments on commit 0a14778

Please sign in to comment.