Skip to content

Commit

Permalink
fix: cleanup bin contents
Browse files Browse the repository at this point in the history
This removes `directories.bin` from npm's `package.json` since it
instead uses the `bin` object syntax to create the bins for `npm` and
`npx`. The non-JS files in that directory are used by the Node
installer, and are not actually bin files that npm is responsible for
linking.

This also does a few items of cleanup around those `bin/` files:

- Removes the unused `node-gyp-bin` files. Those are remnants from
  before `@npmcli/run-script` was introduced in `npm@7`. Now that
  package is responsible for setting `PATH` with the appropriate
  `node-gyp` bin.
- Fixes an issue in `bin/npx` where the exit code was not being read
  from the `npx prefix` call.
- Test the contents of the `bin/(npm|npx)(.cmd)?` files to ensure the
  only differences between them are `npm -> npx`
  • Loading branch information
lukekarrys committed Jun 14, 2023
1 parent 62b65d3 commit 05aee06
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
7 changes: 0 additions & 7 deletions package.json
Expand Up @@ -34,7 +34,6 @@
},
"directories": {
"doc": "./doc",
"lib": "./lib",
"man": "./man"
},
"main": "./index.js",
Expand Down Expand Up @@ -213,14 +212,10 @@
"test-all": "node . run test -ws -iwr --if-present",
"snap": "tap",
"prepack": "node . run build -w docs",
"test:nocleanup": "NO_TEST_CLEANUP=1 node . run test --",
"sudotest": "sudo node . run run test --",
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 node . run test --",
"posttest": "node . run lint",
"lint": "eslint \"**/*.js\"",
"lintfix": "node . run lint -- --fix",
"lint-all": "node . run lint -ws -iwr --if-present",
"prelint": "rimraf test/npm_cache*",
"resetdeps": "node scripts/resetdeps.js",
"rp-pull-request": "node scripts/update-authors.js",
"postlint": "template-oss-check",
Expand All @@ -230,8 +225,6 @@
"test-env": [
"LC_ALL=sk"
],
"color": 1,
"files": "test/{lib,bin,index.js}",
"timeout": 600,
"nyc-arg": [
"--exclude",
Expand Down
1 change: 0 additions & 1 deletion tap-snapshots/test/lib/commands/publish.js.test.cjs
Expand Up @@ -115,7 +115,6 @@ Object {
"description": "a package manager for JavaScript",
"directories": Object {
"doc": "./doc",
"lib": "./lib",
"man": "./man",
},
"exports": Object {
Expand Down
8 changes: 1 addition & 7 deletions workspaces/arborist/package.json
Expand Up @@ -74,18 +74,12 @@
"bin": {
"arborist": "bin/index.js"
},
"//": "sk test-env locale to catch locale-specific sorting",
"tap": {
"color": true,
"after": "test/fixtures/cleanup.js",
"test-env": [
"NODE_OPTIONS=--no-warnings",
"LC_ALL=sk"
],
"node-arg": [
"--no-warnings",
"--no-deprecation"
],
"color": 1,
"timeout": "360",
"nyc-arg": [
"--exclude",
Expand Down
12 changes: 6 additions & 6 deletions workspaces/arborist/test/isolated-mode.js
Expand Up @@ -902,7 +902,7 @@ tap.test('bundled dependencies of internal packages', async t => {
rule7.apply(t, dir, resolved, asserted)

const isexePath = path.join(dir, 'node_modules', 'isexe')
t.equals(isexePath, fs.realpathSync(isexePath))
t.equal(isexePath, fs.realpathSync(isexePath))
})

tap.test('nested bundled dependencies of internal packages', async t => {
Expand Down Expand Up @@ -954,7 +954,7 @@ tap.test('nested bundled dependencies of internal packages', async t => {
rule7.apply(t, dir, resolved, asserted)

const isexePath = path.join(dir, 'node_modules', 'isexe')
t.equals(isexePath, fs.realpathSync(isexePath))
t.equal(isexePath, fs.realpathSync(isexePath))
})

tap.test('nested bundled dependencies of workspaces', async t => {
Expand Down Expand Up @@ -998,9 +998,9 @@ tap.test('nested bundled dependencies of workspaces', async t => {
rule7.apply(t, dir, resolved, asserted)

const isexePath = path.join(dir, 'node_modules', 'isexe')
t.equals(isexePath, fs.realpathSync(isexePath))
t.equal(isexePath, fs.realpathSync(isexePath))
const whichPath = path.join(dir, 'node_modules', 'which')
t.equals(whichPath, fs.realpathSync(whichPath))
t.equal(whichPath, fs.realpathSync(whichPath))
})

tap.test('nested bundled dependencies of workspaces with conflicting isolated dep', async t => {
Expand Down Expand Up @@ -1054,9 +1054,9 @@ tap.test('nested bundled dependencies of workspaces with conflicting isolated de
rule7.apply(t, dir, resolved, asserted)

const isexePath = path.join(dir, 'packages', 'bar', 'node_modules', 'isexe')
t.equals(isexePath, fs.realpathSync(isexePath))
t.equal(isexePath, fs.realpathSync(isexePath))
const whichPath = path.join(dir, 'packages', 'bar', 'node_modules', 'which')
t.equals(whichPath, fs.realpathSync(whichPath))
t.equal(whichPath, fs.realpathSync(whichPath))
})

tap.test('adding a dependency', async t => {
Expand Down

0 comments on commit 05aee06

Please sign in to comment.