Tweaks to preinstall script

This commit is contained in:
Dirk Baeumer
2022-02-02 17:10:31 +01:00
parent 142637c00e
commit 6ea4b6961d

View File

@@ -90,20 +90,20 @@ function installHeaders() {
// file checked into our repository. So from that point it is save to construct the path
// to that executable
const node_gyp = path.join(__dirname, 'gyp', 'node_modules', '.bin', 'node-gyp.cmd');
const result = cp.execSync(`${node_gyp} list`, { encoding: 'utf8' });
const versions = new Set(result.split(/\n/g).filter(line => !line.startsWith('gyp info')).map(value => `"${value}"`));
const result = cp.execFileSync(node_gyp, ['list'], { encoding: 'utf8' });
const versions = new Set(result.split(/\n/g).filter(line => !line.startsWith('gyp info')).map(value => value));
const local = getHeaderInfo(path.join(__dirname, '..', '..', '.yarnrc'));
const remote = getHeaderInfo(path.join(__dirname, '..', '..', 'remote', '.yarnrc'));
if (local !== undefined && !versions.has(local.target)) {
// Both disturl and target come from a file checked into our repository
cp.execSync(`${node_gyp} install --dist-url ${local.disturl} ${local.target}`);
cp.execFileSync(node_gyp, ['install', '--dist-url', local.disturl, local.target]);
}
if (remote !== undefined && !versions.has(remote.target)) {
// Both disturl and target come from a file checked into our repository
cp.execSync(`${node_gyp} install --dist-url ${remote.disturl} ${remote.target}`);
cp.execFileSync(node_gyp, ['install', '--dist-url', remote.disturl, remote.target]);
}
}
@@ -115,11 +115,11 @@ function getHeaderInfo(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*(.*)$/);
let match = line.match(/\s*disturl\s*\"(.*)\"\s*$/);
if (match !== null && match.length >= 1) {
disturl = match[1];
}
match = line.match(/\s*target\s*(.*)$/);
match = line.match(/\s*target\s*\"(.*)\"\s*$/);
if (match !== null && match.length >= 1) {
target = match[1];
}