summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-09-26 09:36:25 -0700
committerGitHub <noreply@github.com>2024-09-26 09:36:25 -0700
commit13c53d9727e0e529d04fd8b7709cb84b723fb0d8 (patch)
tree67ddfa9cff0a30ad503714594cffe059fc044fd3 /tests
parent7437f9d944175d7d62fa34c6a2a186c0cd1684a0 (diff)
fix(installl): make bin entries executable even if not put in `node_modules/.bin` (#25873)
Fixes https://github.com/denoland/deno/issues/25862. npm only makes bin entries executable if they get linked into `.bin`, as we did before this PR. So this PR actually deviates from npm, because it's the only reasonable way to fix this that I can think of. --- The reason this was broken in moment is the following: Moment has dependencies on two typescript versions: 1.8 and 3.1 If you have two packages with conflicting bin entries (i.e. two typescript versions which both have a bin entry `tsc`), in npm it is non-deterministic and undefined which one will end up in `.bin`. npm, due to implementation differences, chooses to put typescript 1.8 into the `.bin` directory, and so `node_modules/typescript/bin/tsc` ends up getting marked executable. We, however, choose typescript 3.2, and so we end up making `node_modules/typescript3/bin/tsc` executable. As part of its tests, moment executes `node_modules/typescript/bin/tsc`. Because we didn't make it executable, this fails. Since the conflict resolution is undefined in npm, instead of trying to match it, I think it makes more sense to just make bin entries executable even if they aren't chosen in the case of a conflict.
Diffstat (limited to 'tests')
-rw-r--r--tests/registry/npm/@denotest/bin/1.0.0/cli-cjs.js2
-rw-r--r--tests/specs/npm/bin_entries_prefer_closer/__test__.jsonc7
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/registry/npm/@denotest/bin/1.0.0/cli-cjs.js b/tests/registry/npm/@denotest/bin/1.0.0/cli-cjs.js
index 7b6ba2724..671e0c4a5 100644
--- a/tests/registry/npm/@denotest/bin/1.0.0/cli-cjs.js
+++ b/tests/registry/npm/@denotest/bin/1.0.0/cli-cjs.js
@@ -1,3 +1,5 @@
+#!/usr/bin/env -S node
+
const process = require("process");
for (const arg of process.argv.slice(2)) {
diff --git a/tests/specs/npm/bin_entries_prefer_closer/__test__.jsonc b/tests/specs/npm/bin_entries_prefer_closer/__test__.jsonc
index 92d43e761..4e9c682df 100644
--- a/tests/specs/npm/bin_entries_prefer_closer/__test__.jsonc
+++ b/tests/specs/npm/bin_entries_prefer_closer/__test__.jsonc
@@ -18,6 +18,13 @@
{
"args": "task run-no-ext",
"output": "Task run-no-ext cli-no-ext hello world\n@denotest/bin 0.7.0\n"
+ },
+ {
+ // even though we didn't put it in .bin, make sure the bin entry is marked executable
+ "if": "unix",
+ "commandName": "node_modules/.deno/@denotest+bin@1.0.0/node_modules/@denotest/bin/cli-cjs.js",
+ "args": "hello",
+ "output": "hello\n"
}
]
}