From a379009bfdddc56d6400740ad7be86f8930952ab Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Wed, 29 May 2024 17:45:22 -0700 Subject: fix(cli): Prefer npm bin entries provided by packages closer to the root (#24024) Fixes #24012. In the case of multiple packages providing a binary with a same name, we were basically leaving the results undefined (since we set up things in parallel, and whichever got set up first won). In addition, we were warning about these cases, even though it's a situation that's expected to occur. Instead, in the case of a collision in the binary names, we prefer the binary provided by the package with the least depth in the dependency tree. While I was at it, I also took moved more code to `bin_entries.rs` since it was starting to get a bit cluttered. --- tests/registry/npm/@denotest/bin/0.7.0/cli-no-ext | 3 +++ tests/registry/npm/@denotest/bin/0.7.0/cli.mjs | 3 +++ tests/registry/npm/@denotest/bin/0.7.0/package.json | 8 ++++++++ tests/registry/npm/@denotest/transitive-bin/1.0.0/cli-cjs.js | 1 + tests/registry/npm/@denotest/transitive-bin/1.0.0/package.json | 10 ++++++++++ 5 files changed, 25 insertions(+) create mode 100644 tests/registry/npm/@denotest/bin/0.7.0/cli-no-ext create mode 100644 tests/registry/npm/@denotest/bin/0.7.0/cli.mjs create mode 100644 tests/registry/npm/@denotest/bin/0.7.0/package.json create mode 100644 tests/registry/npm/@denotest/transitive-bin/1.0.0/cli-cjs.js create mode 100644 tests/registry/npm/@denotest/transitive-bin/1.0.0/package.json (limited to 'tests/registry') diff --git a/tests/registry/npm/@denotest/bin/0.7.0/cli-no-ext b/tests/registry/npm/@denotest/bin/0.7.0/cli-no-ext new file mode 100644 index 000000000..1cad127ca --- /dev/null +++ b/tests/registry/npm/@denotest/bin/0.7.0/cli-no-ext @@ -0,0 +1,3 @@ +#!/usr/bin/env -S node + +console.log("@denotest/bin 0.7.0"); diff --git a/tests/registry/npm/@denotest/bin/0.7.0/cli.mjs b/tests/registry/npm/@denotest/bin/0.7.0/cli.mjs new file mode 100644 index 000000000..1cad127ca --- /dev/null +++ b/tests/registry/npm/@denotest/bin/0.7.0/cli.mjs @@ -0,0 +1,3 @@ +#!/usr/bin/env -S node + +console.log("@denotest/bin 0.7.0"); diff --git a/tests/registry/npm/@denotest/bin/0.7.0/package.json b/tests/registry/npm/@denotest/bin/0.7.0/package.json new file mode 100644 index 000000000..d66b6e34d --- /dev/null +++ b/tests/registry/npm/@denotest/bin/0.7.0/package.json @@ -0,0 +1,8 @@ +{ + "name": "@denotest/bin", + "version": "0.7.0", + "bin": { + "cli-esm": "./cli.mjs", + "cli-no-ext": "./cli-no-ext" + } +} diff --git a/tests/registry/npm/@denotest/transitive-bin/1.0.0/cli-cjs.js b/tests/registry/npm/@denotest/transitive-bin/1.0.0/cli-cjs.js new file mode 100644 index 000000000..f517654b9 --- /dev/null +++ b/tests/registry/npm/@denotest/transitive-bin/1.0.0/cli-cjs.js @@ -0,0 +1 @@ +console.log("@denotest/transitive-bin 1.0.0"); diff --git a/tests/registry/npm/@denotest/transitive-bin/1.0.0/package.json b/tests/registry/npm/@denotest/transitive-bin/1.0.0/package.json new file mode 100644 index 000000000..84d780516 --- /dev/null +++ b/tests/registry/npm/@denotest/transitive-bin/1.0.0/package.json @@ -0,0 +1,10 @@ +{ + "name": "@denotest/transitive-bin", + "version": "1.0.0", + "dependencies": { + "@denotest/bin": "1.0.0" + }, + "bin": { + "cli-cjs": "cli-cjs.js" + } +} \ No newline at end of file -- cgit v1.2.3