Created
October 1, 2020 17:41
-
-
Save isaacs/909cbb9cdfe1589692b9dd7e809e0f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/arborist/rebuild.js b/lib/arborist/rebuild.js | |
index fd7be34..0932089 100644 | |
--- a/lib/arborist/rebuild.js | |
+++ b/lib/arborist/rebuild.js | |
@@ -8,7 +8,10 @@ const binLinks = require('bin-links') | |
const runScript = require('@npmcli/run-script') | |
const promiseCallLimit = require('promise-call-limit') | |
const {resolve} = require('path') | |
-const { isNodeGypPackage } = require('@npmcli/node-gyp') | |
+const { | |
+ isNodeGypPackage, | |
+ defaultGypInstallScript, | |
+} = require('@npmcli/node-gyp') | |
const boolEnv = b => b ? '1' : '' | |
const sortNodes = (a, b) => (a.depth - b.depth) || a.path.localeCompare(b.path) | |
@@ -175,15 +178,19 @@ module.exports = cls => class Builder extends cls { | |
} | |
} | |
- if (bin || preinstall || install || postinstall) { | |
+ // Rebuild node-gyp dependencies lacking an install or preinstall script | |
+ // note that 'scripts' might be missing entirely. | |
+ const isGyp = node.package.gypfile !== false && | |
+ !install && | |
+ !preinstall && | |
+ await isNodeGypPackage(node.path) | |
+ if (bin || preinstall || install || postinstall || isGyp) { | |
if (bin) | |
await this[_checkBins](node) | |
- set.add(node) | |
- } else if (!install && !preinstall && await isNodeGypPackage(node.path)) { | |
- // Rebuild node-gyp dependencies lacking an install or preinstall script | |
- // note that 'scripts' might be missing entirely. | |
- scripts.install = 'node-gyp rebuild' | |
- node.package.scripts = scripts | |
+ if (isGyp) { | |
+ scripts.install = defaultGypInstallScript | |
+ node.package.scripts = scripts | |
+ } | |
set.add(node) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment