Skip to content

Commit a726cef

Browse files
committed
Check that modules in both the base package.json and remote/ have the same version installed
1 parent 525f927 commit a726cef

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

build/npm/postinstall.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,42 @@ const processTreeDts = path.join('node_modules', 'windows-process-tree', 'typing
7878
if (fs.existsSync(processTreeDts)) {
7979
console.log('Removing windows-process-tree.d.ts');
8080
fs.unlinkSync(processTreeDts);
81-
}
81+
}
82+
83+
function getInstalledVersion(packageName, cwd) {
84+
const opts = {};
85+
if (cwd) {
86+
opts.cwd = cwd;
87+
}
88+
89+
const result = cp.spawnSync(yarn, ['list', '--pattern', packageName], opts);
90+
const stdout = result.stdout.toString();
91+
const match = stdout.match(new RegExp(packageName + '@(\\S+)'));
92+
if (!match || !match[1]) {
93+
throw new Error('Unexpected output from yarn list: ' + stdout);
94+
}
95+
96+
return match[1];
97+
}
98+
99+
function assertSameVersionsBetweenFolders(packageName, otherFolder) {
100+
const baseVersion = getInstalledVersion(packageName);
101+
const otherVersion = getInstalledVersion(packageName, otherFolder);
102+
103+
if (baseVersion !== otherVersion) {
104+
throw new Error(`Mismatched versions installed for ${packageName}: root has ${baseVersion}, ./${otherFolder} has ${otherVersion}. These should be the same!`);
105+
}
106+
}
107+
108+
// Check that modules in both the base package.json and remote/ have the same version installed
109+
const requireSameVersionsInRemote = [
110+
'xterm',
111+
'xterm-addon-search',
112+
'xterm-addon-web-links',
113+
'node-pty',
114+
'vscode-ripgrep'
115+
];
116+
117+
requireSameVersionsInRemote.forEach(packageName => {
118+
assertSameVersionsBetweenFolders(packageName, 'remote');
119+
});

0 commit comments

Comments
 (0)