Skip to content

Commit f656676

Browse files
committed
Put npm-prefix in test dir bin
1 parent 073033b commit f656676

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/bin/windows-shims.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ const Diff = require('diff')
66
const { sync: which } = require('which')
77
const { version } = require('../../package.json')
88

9-
const readShimFiles = (dir) => readdirSync(dir).reduce((acc, shim) => {
9+
const readNonJsFiles = (dir) => readdirSync(dir).reduce((acc, shim) => {
1010
const p = join(dir, shim)
11-
if (!p.endsWith('-cli.js') && !statSync(p).isDirectory()) {
11+
if (extname(p) !== '.js' && !statSync(p).isDirectory()) {
1212
acc[shim] = readFileSync(p, 'utf-8')
1313
}
1414
return acc
1515
}, {})
1616

1717
const ROOT = resolve(__dirname, '../..')
1818
const BIN = join(ROOT, 'bin')
19-
const SHIMS = readShimFiles(BIN)
20-
const NODE_GYP = readShimFiles(join(BIN, 'node-gyp-bin'))
21-
const SHIM_EXTS = [...new Set(Object.keys(SHIMS).map(p => extname(p)).filter(p => p !== '.js'))]
19+
const SHIMS = readNonJsFiles(BIN)
20+
const NODE_GYP = readNonJsFiles(join(BIN, 'node-gyp-bin'))
21+
const SHIM_EXTS = [...new Set(Object.keys(SHIMS).map(p => extname(p)))]
2222

2323
// windows requires each segment of a command path to be quoted when using shell: true
2424
const quotePath = (cmd) => cmd
@@ -94,6 +94,7 @@ t.test('run shims', t => {
9494
node_modules: {
9595
npm: {
9696
bin: {
97+
'npm-prefix.js': readFileSync(join(BIN, 'npm-prefix.js')),
9798
'npx-cli.js': `throw new Error('this should not be called')`,
9899
'npm-cli.js': `
99100
const assert = require('assert')

0 commit comments

Comments
 (0)