From 4d33c64e5c6c2c1e8f3936630286e1181824a722 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 11 Sep 2024 17:46:50 +0200 Subject: [PATCH 1/2] chore: add missing license field in test fixtures --- test/commands.test.ts | 5 +++++ test/test_utils.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/test/commands.test.ts b/test/commands.test.ts index 33b5a46..06b699b 100644 --- a/test/commands.test.ts +++ b/test/commands.test.ts @@ -657,6 +657,7 @@ describe("publish", () => { await writeJson(path.join(dir, "deno.json"), { name: "@deno/jsr-cli-test", version: pkgJson.version!, + license: "MIT", exports: { ".": "./mod.ts", }, @@ -679,6 +680,7 @@ describe("publish", () => { await writeJson(path.join(dir, "deno.json"), { name: "@deno/jsr-cli-test", version: "0.0.1", + license: "MIT", exports: { ".": "./mod.ts", }, @@ -717,6 +719,7 @@ describe("publish", () => { await writeJson(path.join(dir, "jsr.json"), { name: "@deno/jsr-cli-test", version: pkgJson.version!, + license: "MIT", exports: { ".": "./mod.ts", }, @@ -744,6 +747,7 @@ describe("publish", () => { await writeJson(path.join(dir, "deno.json"), { name: "@deno/jsr-cli-test", version: "1.0.0", + license: "MIT", exports: { ".": "./mod.ts", }, @@ -766,6 +770,7 @@ describe("publish", () => { await writeJson(path.join(dir, "deno.json"), { name: "@deno/jsr-cli-test", version: "1.0.0", + license: "MIT", exports: { ".": "./mod.ts", }, diff --git a/test/test_utils.ts b/test/test_utils.ts index 14067f9..9b8eb20 100644 --- a/test/test_utils.ts +++ b/test/test_utils.ts @@ -7,6 +7,7 @@ export interface DenoJson { name: string; version: string; exports: string | Record; + license: string; } /** From 9f414fb532992b80326288e4019f121d971aa6bc Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 11 Sep 2024 17:49:03 +0200 Subject: [PATCH 2/2] fix: prefer lockfile detection over env var one --- src/pkg_manager.ts | 2 +- test/commands.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pkg_manager.ts b/src/pkg_manager.ts index 8b4a2f4..6b65f26 100644 --- a/src/pkg_manager.ts +++ b/src/pkg_manager.ts @@ -216,7 +216,7 @@ export async function getPkgManager( ); const rootPath = root || projectDir; - const result = pkgManagerName || fromEnv || fromLockfile || "npm"; + const result = pkgManagerName || fromLockfile || fromEnv || "npm"; let pkgManager: PackageManager; if (result === "yarn") { diff --git a/test/commands.test.ts b/test/commands.test.ts index 06b699b..cccbfb4 100644 --- a/test/commands.test.ts +++ b/test/commands.test.ts @@ -503,6 +503,25 @@ describe("install", () => { ); }); + it("prefer lockfile detection over env detection", async () => { + await runInTempDir(async (tmp) => { + await writeJson(path.join(tmp, "package.json"), { + name: "foo", + version: "0.0.1", + dependencies: { + preact: "10.23.2", + }, + }); + + await exec("pnpm", ["install"], tmp); + await runJsr(["i", "@std/encoding@0.216.0"], tmp, { + npm_config_user_agent: + `npm/10.8.2 node/v22.5.1 darwin arm64 workspaces/false`, + }); + assert.ok(!fs.existsSync(path.join(tmp, "package-lock.json"))); + }); + }); + it("overwrite detection with arg from npm_config_user_agent", async () => { await withTempEnv( ["i", "--npm", "@std/encoding@0.216.0"],