Add script to prefetch headers for native module compile

This commit is contained in:
Dirk Baeumer 2021-11-24 21:44:29 +01:00
parent bfad20be9d
commit e346d0f1f9
No known key found for this signature in database
GPG key ID: DD95715335E91385
2 changed files with 39 additions and 1 deletions

37
build/prefetchHeaders.js Normal file
View file

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const fs = require('fs');
const cp = require('child_process');
function installHeaders(rcFile) {
const lines = fs.readFileSync(rcFile, 'utf8').split(/\r\n?/g);
let disturl, target;
for (const line of lines) {
let match = line.match(/\s*disturl\s*(.*)$/);
if (match !== null && match.length >= 1) {
disturl = match[1];
}
match = line.match(/\s*target\s*(.*)$/);
if (match !== null && match.length >= 1) {
target = match[1];
}
}
if (disturl !== undefined && target !== undefined) {
console.log(`Pre-fetch headers for ${target} from ${disturl}`);
cp.execSync(`node-gyp install --dist-url ${disturl} ${target}`);
}
}
function main() {
installHeaders(path.join(__dirname, '..', '.yarnrc'));
installHeaders(path.join(__dirname, '..', 'remote', '.yarnrc'));
}
if (require.main === module) {
main();
}

View file

@ -55,7 +55,8 @@
"minify-vscode-reh-web": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js minify-vscode-reh-web",
"hygiene": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js hygiene",
"core-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js core-ci",
"extensions-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js extensions-ci"
"extensions-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js extensions-ci",
"refetch-headers": "node build/prefetchHeaders.js"
},
"dependencies": {
"@microsoft/applicationinsights-web": "^2.6.4",