@@ -6,19 +6,19 @@ const Diff = require('diff')
6
6
const { sync : which } = require ( 'which' )
7
7
const { version } = require ( '../../package.json' )
8
8
9
- const readShimFiles = ( dir ) => readdirSync ( dir ) . reduce ( ( acc , shim ) => {
9
+ const readNonJsFiles = ( dir ) => readdirSync ( dir ) . reduce ( ( acc , shim ) => {
10
10
const p = join ( dir , shim )
11
- if ( ! p . endsWith ( '-cli .js') && ! statSync ( p ) . isDirectory ( ) ) {
11
+ if ( extname ( p ) !== ' .js' && ! statSync ( p ) . isDirectory ( ) ) {
12
12
acc [ shim ] = readFileSync ( p , 'utf-8' )
13
13
}
14
14
return acc
15
15
} , { } )
16
16
17
17
const ROOT = resolve ( __dirname , '../..' )
18
18
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 ) ) ) ]
22
22
23
23
// windows requires each segment of a command path to be quoted when using shell: true
24
24
const quotePath = ( cmd ) => cmd
@@ -94,6 +94,7 @@ t.test('run shims', t => {
94
94
node_modules : {
95
95
npm : {
96
96
bin : {
97
+ 'npm-prefix.js' : readFileSync ( join ( BIN , 'npm-prefix.js' ) ) ,
97
98
'npx-cli.js' : `throw new Error('this should not be called')` ,
98
99
'npm-cli.js' : `
99
100
const assert = require('assert')
0 commit comments