+76
-9
lines changedFilter options
+76
-9
lines changed Original file line number Diff line number Diff line change
@@ -129,14 +129,14 @@ class RunScript extends BaseCommand {
129
129
130
130
for (const [ev, evArgs] of events) {
131
131
await runScript({
132
+
args: evArgs,
133
+
event: ev,
134
+
nodeGyp: this.npm.config.get('node-gyp'),
132
135
path,
133
-
// this || undefined is because runScript will be unhappy with the
134
-
// default null value
136
+
pkg,
137
+
// || undefined is because runScript will be unhappy with the default null value
135
138
scriptShell: this.npm.config.get('script-shell') || undefined,
136
139
stdio: 'inherit',
137
-
pkg,
138
-
event: ev,
139
-
args: evArgs,
140
140
})
141
141
}
142
142
}
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
98
98
"long": false,
99
99
"maxsockets": 15,
100
100
"message": "%s",
101
+
"node-gyp": "{CWD}/node_modules/node-gyp/bin/node-gyp.js",
101
102
"node-options": null,
102
103
"noproxy": [
103
104
""
@@ -263,6 +264,7 @@ logs-max = 10
263
264
; long = false ; overridden by cli
264
265
maxsockets = 15
265
266
message = "%s"
267
+
node-gyp = "{CWD}/node_modules/node-gyp/bin/node-gyp.js"
266
268
node-options = null
267
269
noproxy = [""]
268
270
npm-version = "{NPM-VERSION}"
Original file line number Diff line number Diff line change
@@ -1072,6 +1072,19 @@ Any "%s" in the message will be replaced with the version number.
1072
1072
1073
1073
1074
1074
1075
+
#### \`node-gyp\`
1076
+
1077
+
* Default: The path to the node-gyp bin that ships with npm
1078
+
* Type: Path
1079
+
1080
+
This is the location of the "node-gyp" bin. By default it uses one that
1081
+
ships with npm itself.
1082
+
1083
+
You can use this config to specify your own "node-gyp" to run when it is
1084
+
required to build a package.
1085
+
1086
+
1087
+
1075
1088
#### \`node-options\`
1076
1089
1077
1090
* Default: null
@@ -2158,6 +2171,7 @@ Array [
2158
2171
"long",
2159
2172
"maxsockets",
2160
2173
"message",
2174
+
"node-gyp",
2161
2175
"node-options",
2162
2176
"noproxy",
2163
2177
"offline",
@@ -2300,6 +2314,7 @@ Array [
2300
2314
"loglevel",
2301
2315
"maxsockets",
2302
2316
"message",
2317
+
"node-gyp",
2303
2318
"noproxy",
2304
2319
"offline",
2305
2320
"omit",
@@ -2454,6 +2469,7 @@ Object {
2454
2469
"maxSockets": 15,
2455
2470
"message": "%s",
2456
2471
"nodeBin": "{NODE}",
2472
+
"nodeGyp": "{CWD}/node_modules/node-gyp/bin/node-gyp.js",
2457
2473
"nodeVersion": "2.2.2",
2458
2474
"noProxy": "",
2459
2475
"npmBin": "{CWD}/other/bin/npm-cli.js",
Original file line number Diff line number Diff line change
@@ -347,6 +347,7 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => {
347
347
env: 'env',
348
348
},
349
349
},
350
+
nodeGyp: npm.config.get('node-gyp'),
350
351
event: 'env',
351
352
},
352
353
])
@@ -485,6 +486,25 @@ t.test('list scripts, only non-commands', async t => {
485
486
t.matchSnapshot(joinedOutput())
486
487
})
487
488
489
+
t.test('node-gyp config', async t => {
490
+
const { runScript, RUN_SCRIPTS, npm } = await mockRs(t, {
491
+
prefixDir: {
492
+
'package.json': JSON.stringify({
493
+
name: 'x',
494
+
version: '1.2.3',
495
+
}),
496
+
},
497
+
config: { 'node-gyp': '/test/node-gyp.js' },
498
+
})
499
+
500
+
await runScript.exec(['env'])
501
+
t.match(RUN_SCRIPTS(), [
502
+
{
503
+
nodeGyp: npm.config.get('node-gyp'),
504
+
},
505
+
])
506
+
})
507
+
488
508
t.test('workspaces', async t => {
489
509
const mockWorkspaces = async (t, {
490
510
runScript,
Original file line number Diff line number Diff line change
@@ -1294,6 +1294,19 @@ const definitions = {
1294
1294
`,
1295
1295
flatten,
1296
1296
}),
1297
+
'node-gyp': new Definition('node-gyp', {
1298
+
default: require.resolve('node-gyp/bin/node-gyp.js'),
1299
+
defaultDescription: `
1300
+
The path to the node-gyp bin that ships with npm
1301
+
`,
1302
+
type: path,
1303
+
description: `
1304
+
This is the location of the "node-gyp" bin. By default it uses one that ships with npm itself.
1305
+
1306
+
You can use this config to specify your own "node-gyp" to run when it is required to build a package.
1307
+
`,
1308
+
flatten,
1309
+
}),
1297
1310
'node-options': new Definition('node-options', {
1298
1311
default: null,
1299
1312
type: [null, String],
Original file line number Diff line number Diff line change
@@ -15,12 +15,11 @@ const {
15
15
mkdir,
16
16
} = require('node:fs/promises')
17
17
18
-
// TODO these need to be either be ignored when parsing env, formalized as config, or not exported to the env in the first place. For now this list is just to suppress warnings till we can pay off this tech debt.
18
+
// TODO global-prefix and local-prefix are set by lib/set-envs.js. This may not be the best way to persist those, if we even want to persist them (see set-envs.js)
19
19
const internalEnv = [
20
+
'npm-version',
20
21
'global-prefix',
21
22
'local-prefix',
22
-
'npm-version',
23
-
'node-gyp',
24
23
]
25
24
26
25
const fileExists = (...p) => stat(resolve(...p))
@@ -282,7 +281,7 @@ class Config {
282
281
}
283
282
284
283
try {
285
-
// This does not have an actual definition
284
+
// This does not have an actual definition because this is not user defineable
286
285
defaultsObject['npm-version'] = require(join(this.npmPath, 'package.json')).version
287
286
} catch {
288
287
// in some weird state where the passed in npmPath does not have a package.json
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ const setEnvs = (config) => {
90
90
91
91
// also set some other common nice envs that we want to rely on
92
92
env.HOME = config.home
93
+
// TODO this may not be the best away to persist these
93
94
env.npm_config_global_prefix = config.globalPrefix
94
95
env.npm_config_local_prefix = config.localPrefix
95
96
if (cliConf.editor) {
@@ -101,6 +102,10 @@ const setEnvs = (config) => {
101
102
if (cliConf['node-options']) {
102
103
env.NODE_OPTIONS = cliConf['node-options']
103
104
}
105
+
// the node-gyp bin uses this so we always set it
106
+
env.npm_config_node_gyp = cliConf['node-gyp']
107
+
// this doesn't have a full definition so we manually export it here
108
+
env.npm_config_npm_version = cliConf['npm-version'] || 'unknown'
104
109
env.npm_execpath = config.npmBin
105
110
env.NODE = env.npm_node_execpath = config.execPath
106
111
}
Original file line number Diff line number Diff line change
@@ -325,6 +325,9 @@ Object {
325
325
"message": Array [
326
326
Function String(),
327
327
],
328
+
"node-gyp": Array [
329
+
"valid filesystem path",
330
+
],
328
331
"node-options": Array [
329
332
null,
330
333
Function String(),
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const NODE = execPath
11
11
12
12
const npmPath = '{path}'
13
13
const npmBin = join(npmPath, 'bin/npm-cli.js')
14
+
const nodeGypPath = require.resolve('node-gyp/bin/node-gyp.js')
14
15
15
16
const mockDefinitions = (t) => {
16
17
mockGlobals(t, { 'process.env': { EDITOR: 'vim' } })
@@ -27,6 +28,8 @@ t.test('set envs that are not defaults and not already in env', t => {
27
28
INIT_CWD: cwd,
28
29
EDITOR: 'vim',
29
30
HOME: undefined,
31
+
npm_config_node_gyp: nodeGypPath,
32
+
npm_config_npm_version: 'unknown',
30
33
npm_execpath: npmBin,
31
34
npm_node_execpath: execPath,
32
35
npm_config_global_prefix: globalPrefix,
@@ -80,6 +83,8 @@ t.test('set envs that are not defaults and not already in env, array style', t =
80
83
INIT_CWD: cwd,
81
84
EDITOR: 'vim',
82
85
HOME: undefined,
86
+
npm_config_node_gyp: nodeGypPath,
87
+
npm_config_npm_version: 'unknown',
83
88
npm_execpath: npmBin,
84
89
npm_node_execpath: execPath,
85
90
npm_config_global_prefix: globalPrefix,
@@ -130,6 +135,8 @@ t.test('set envs that are not defaults and not already in env, boolean edition',
130
135
INIT_CWD: cwd,
131
136
EDITOR: 'vim',
132
137
HOME: undefined,
138
+
npm_config_node_gyp: nodeGypPath,
139
+
npm_config_npm_version: 'unknown',
133
140
npm_execpath: npmBin,
134
141
npm_node_execpath: execPath,
135
142
npm_config_global_prefix: globalPrefix,
@@ -207,6 +214,8 @@ t.test('dont set configs marked as envExport:false', t => {
207
214
INIT_CWD: cwd,
208
215
EDITOR: 'vim',
209
216
HOME: undefined,
217
+
npm_config_node_gyp: nodeGypPath,
218
+
npm_config_npm_version: 'unknown',
210
219
npm_execpath: npmBin,
211
220
npm_node_execpath: execPath,
212
221
npm_config_global_prefix: globalPrefix,
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4