Skip to content

Commit 0dba79a

Browse files
committed
fix: add back bin/node-gyp-bin/node-gyp files
This is a continuation of #6932. This makes a few more changes identified in also porting these changes to v10.
1 parent c93edb5 commit 0dba79a

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/configure text eol=lf
88

99
# our cmd scripts always need to be CRLF
10-
/bin/*.cmd text eol=crlf
10+
/bin/**/*.cmd text eol=crlf
1111

1212
# ignore all line endings in node_modules since we dont control that
1313
/node_modules/** -text

bin/node-gyp-bin/node-gyp.cmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
if not defined npm_config_node_gyp (
2-
node "%~dp0\..\..\node_modules\node-gyp\bin\node-gyp.js" %*
3-
) else (
1+
if not defined npm_config_node_gyp (
2+
node "%~dp0\..\..\node_modules\node-gyp\bin\node-gyp.js" %*
3+
) else (
44
node "%npm_config_node_gyp%" %*
5-
)
5+
)

test/bin/windows-shims.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
const t = require('tap')
22
const { spawnSync } = require('child_process')
33
const { resolve, join, extname, basename, sep } = require('path')
4-
const { readFileSync, chmodSync, readdirSync, statSync } = require('fs')
4+
const { readFileSync, chmodSync, readdirSync, rmSync, statSync } = require('fs')
55
const Diff = require('diff')
66
const { sync: which } = require('which')
77
const { version } = require('../../package.json')
88

9-
const ROOT = resolve(__dirname, '../..')
10-
const BIN = join(ROOT, 'bin')
11-
const NODE = readFileSync(process.execPath)
12-
const SHIMS = readdirSync(BIN).reduce((acc, shim) => {
13-
const p = join(BIN, shim)
9+
const readNonJsFiles = (dir) => readdirSync(dir).reduce((acc, shim) => {
10+
const p = join(dir, shim)
1411
if (extname(p) !== '.js' && !statSync(p).isDirectory()) {
1512
acc[shim] = readFileSync(p, 'utf-8')
1613
}
1714
return acc
1815
}, {})
1916

17+
const ROOT = resolve(__dirname, '../..')
18+
const BIN = join(ROOT, 'bin')
19+
const SHIMS = readNonJsFiles(BIN)
20+
const NODE_GYP = readNonJsFiles(join(BIN, 'node-gyp-bin'))
2021
const SHIM_EXTS = [...new Set(Object.keys(SHIMS).map(p => extname(p)))]
2122

2223
// windows requires each segment of a command path to be quoted when using shell: true
@@ -65,6 +66,21 @@ t.test('shim contents', t => {
6566
})
6667
})
6768

69+
t.test('node-gyp', t => {
70+
// these files need to exist to avoid breaking yarn 1.x
71+
72+
for (const [key, file] of Object.entries(NODE_GYP)) {
73+
t.match(file, /npm_config_node_gyp/, `${key} contains env var`)
74+
t.match(
75+
file,
76+
/[\\/]\.\.[\\/]\.\.[\\/]node_modules[\\/]node-gyp[\\/]bin[\\/]node-gyp\.js/,
77+
`${key} contains path`
78+
)
79+
}
80+
81+
t.end()
82+
})
83+
6884
t.test('run shims', t => {
6985
const path = t.testdir({
7086
...SHIMS,

0 commit comments

Comments
 (0)