Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/npm/update-all-grammars.mjs
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { spawn as _spawn } from 'child_process';
7
import { readdirSync, readFileSync } from 'fs';
8
import { join } from 'path';
9
import url from 'url';
10
11
async function spawn(cmd, args, opts) {
12
return new Promise((c, e) => {
13
const child = _spawn(cmd, args, { shell: true, stdio: 'inherit', env: process.env, ...opts });
14
child.on('close', code => code === 0 ? c() : e(`Returned ${code}`));
15
});
16
}
17
18
async function main() {
19
await spawn('npm', ['ci'], { cwd: 'extensions' });
20
21
for (const extension of readdirSync('extensions')) {
22
try {
23
const packageJSON = JSON.parse(readFileSync(join('extensions', extension, 'package.json')).toString());
24
if (!(packageJSON && packageJSON.scripts && packageJSON.scripts['update-grammar'])) {
25
continue;
26
}
27
} catch {
28
continue;
29
}
30
31
await spawn(`npm`, ['run', 'update-grammar'], { cwd: `extensions/${extension}` });
32
}
33
34
// run integration tests
35
36
if (process.platform === 'win32') {
37
_spawn('.\\scripts\\test-integration.bat', [], { env: process.env, stdio: 'inherit' });
38
} else {
39
_spawn('/bin/bash', ['./scripts/test-integration.sh'], { env: process.env, stdio: 'inherit' });
40
}
41
}
42
43
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
44
main().catch(err => {
45
console.error(err);
46
process.exit(1);
47
});
48
}
49
50