Skip to content

Commit

Permalink
fix: --npm flag not being respected (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Mar 8, 2024
1 parent ec0fdbc commit d4e5408
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ if (args.length === 0) {
? "yarn"
: options.values.bun
? "bun"
: options.values.npm
? "npm"
: null;

if (cmd === "i" || cmd === "install" || cmd === "add") {
Expand Down
19 changes: 19 additions & 0 deletions test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,25 @@ describe("install", () => {
);
});

it("overwrite detection with arg from npm_config_user_agent", async () => {
await withTempEnv(
["i", "--npm", "@std/[email protected]"],
async (dir) => {
assert.ok(
await isFile(path.join(dir, "package-lock.json")),
"npm lockfile not created",
);
},
{
env: {
...process.env,
npm_config_user_agent:
`pnpm/8.14.3 ${process.env.npm_config_user_agent}`,
},
},
);
});

it("detect yarn from npm_config_user_agent", async () => {
await withTempEnv(
["i", "@std/[email protected]"],
Expand Down

0 comments on commit d4e5408

Please sign in to comment.