Skip to content

Commit d4e5408

Browse files
fix: --npm flag not being respected (#52)
1 parent ec0fdbc commit d4e5408

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/bin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ if (args.length === 0) {
196196
? "yarn"
197197
: options.values.bun
198198
? "bun"
199+
: options.values.npm
200+
? "npm"
199201
: null;
200202

201203
if (cmd === "i" || cmd === "install" || cmd === "add") {

test/commands.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,25 @@ describe("install", () => {
336336
);
337337
});
338338

339+
it("overwrite detection with arg from npm_config_user_agent", async () => {
340+
await withTempEnv(
341+
["i", "--npm", "@std/[email protected]"],
342+
async (dir) => {
343+
assert.ok(
344+
await isFile(path.join(dir, "package-lock.json")),
345+
"npm lockfile not created",
346+
);
347+
},
348+
{
349+
env: {
350+
...process.env,
351+
npm_config_user_agent:
352+
`pnpm/8.14.3 ${process.env.npm_config_user_agent}`,
353+
},
354+
},
355+
);
356+
});
357+
339358
it("detect yarn from npm_config_user_agent", async () => {
340359
await withTempEnv(
341360
["i", "@std/[email protected]"],

0 commit comments

Comments
 (0)