Skip to content

Commit 0fe4eda

Browse files
authored
fix: delete all prebuilds if not using any (#829)
1 parent 1148a99 commit 0fe4eda

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scripts/prebuild.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ const path = require('path');
1414
* node scripts/prebuild.js
1515
*/
1616

17+
const PREBUILDS_ROOT = path.join(__dirname, '..', 'prebuilds');
1718
const PREBUILD_DIR = path.join(__dirname, '..', 'prebuilds', `${process.platform}-${process.arch}`);
1819

19-
// Skip copying prebuilds when npm_config_build_from_source is set
20+
// Do not use prebuilds when npm_config_build_from_source is set
2021
if (process.env.npm_config_build_from_source === 'true') {
2122
console.log('\x1b[33m> Removing prebuilds and rebuilding because npm_config_build_from_source is set\x1b[0m');
22-
fs.rmSync(PREBUILD_DIR, { recursive: true });
23+
fs.rmSync(PREBUILDS_ROOT, { recursive: true, force: true });
2324
process.exit(1);
2425
}
2526

26-
/* Copy prebuild files to build/Release */
27-
console.log('\x1b[32m> Copying prebuilds to release folder...\x1b[0m');
27+
// Check whether the correct prebuilt files exist
28+
console.log('\x1b[32m> Checking prebuilds...\x1b[0m');
2829
if (!fs.existsSync(PREBUILD_DIR)) {
29-
console.log(` SKIPPED Prebuild directory ${PREBUILD_DIR} does not exist`);
30-
// Exit with 1 to fall back on node-gyp building the native modules
30+
console.log(`\x1b[33m> Removing prebuilds and rebuilding because directory ${PREBUILD_DIR} does not exist\x1b[0m`);
31+
fs.rmSync(PREBUILDS_ROOT, { recursive: true, force: true });
3132
process.exit(1);
3233
}
33-
// Exit with 0 to skip node-gyp building from source
34+
3435
process.exit(0);

0 commit comments

Comments
 (0)