From e346d0f1f9b3b94302a06805ae6bbb18d95f1e6f Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Wed, 24 Nov 2021 21:44:29 +0100 Subject: [PATCH] Add script to prefetch headers for native module compile --- build/prefetchHeaders.js | 37 +++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 build/prefetchHeaders.js diff --git a/build/prefetchHeaders.js b/build/prefetchHeaders.js new file mode 100644 index 00000000000..030f4aaf1d0 --- /dev/null +++ b/build/prefetchHeaders.js @@ -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(); +} diff --git a/package.json b/package.json index 129bab504cd..4ce4e25985f 100644 --- a/package.json +++ b/package.json @@ -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",