Check that modules in both the base package.json and remote/ have the same version installed

This commit is contained in:
Rob Lourens 2019-08-12 14:51:36 -07:00
parent 525f927adc
commit a726cef3c3

View file

@ -78,4 +78,42 @@ const processTreeDts = path.join('node_modules', 'windows-process-tree', 'typing
if (fs.existsSync(processTreeDts)) {
console.log('Removing windows-process-tree.d.ts');
fs.unlinkSync(processTreeDts);
}
}
function getInstalledVersion(packageName, cwd) {
const opts = {};
if (cwd) {
opts.cwd = cwd;
}
const result = cp.spawnSync(yarn, ['list', '--pattern', packageName], opts);
const stdout = result.stdout.toString();
const match = stdout.match(new RegExp(packageName + '@(\\S+)'));
if (!match || !match[1]) {
throw new Error('Unexpected output from yarn list: ' + stdout);
}
return match[1];
}
function assertSameVersionsBetweenFolders(packageName, otherFolder) {
const baseVersion = getInstalledVersion(packageName);
const otherVersion = getInstalledVersion(packageName, otherFolder);
if (baseVersion !== otherVersion) {
throw new Error(`Mismatched versions installed for ${packageName}: root has ${baseVersion}, ./${otherFolder} has ${otherVersion}. These should be the same!`);
}
}
// Check that modules in both the base package.json and remote/ have the same version installed
const requireSameVersionsInRemote = [
'xterm',
'xterm-addon-search',
'xterm-addon-web-links',
'node-pty',
'vscode-ripgrep'
];
requireSameVersionsInRemote.forEach(packageName => {
assertSameVersionsBetweenFolders(packageName, 'remote');
});