Skip to content

Commit 18186ac

Browse files
committed
no throw on errors when auto-locating node-gyp
1 parent 73cd050 commit 18186ac

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/make-spawn-args.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
const setPATH = require('./set-path.js')
33
const { resolve } = require('path')
44
let npm_config_node_gyp
5-
if (typeof require === 'function' && typeof require.resolve === 'function') {
6-
npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
5+
try {
6+
/* istanbul ignore next */
7+
if (typeof require === 'function' && typeof require.resolve === 'function') {
8+
npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
9+
}
10+
} catch(er) {
11+
/* istanbul ignore next */
12+
console.warn('> @npmcli/run-script: Failed auto-locating `node-gyp`')
713
}
814

915
const makeSpawnArgs = options => {
@@ -27,6 +33,7 @@ const makeSpawnArgs = options => {
2733
npm_lifecycle_event: event,
2834
npm_lifecycle_script: cmd,
2935
})
36+
/* istanbul ignore next */
3037
if (typeof npm_config_node_gyp === 'string') {
3138
spawnEnv.npm_config_node_gyp = npm_config_node_gyp
3239
}

0 commit comments

Comments
 (0)