vscode/build/npm/update-all-grammars.mjs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-05-25 09:27:32 +00:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { spawn as _spawn } from 'child_process';
import { readdirSync, readFileSync } from 'fs';
import { join } from 'path';
import url from 'url';
2017-05-25 09:27:32 +00:00
2021-02-02 11:30:08 +00:00
async function spawn(cmd, args, opts) {
return new Promise((c, e) => {
const child = _spawn(cmd, args, { shell: true, stdio: 'inherit', env: process.env, ...opts });
2021-02-02 11:30:08 +00:00
child.on('close', code => code === 0 ? c() : e(`Returned ${code}`));
2017-05-25 09:27:32 +00:00
});
}
2021-02-02 11:30:08 +00:00
async function main() {
await spawn('yarn', [], { cwd: 'extensions' });
for (const extension of readdirSync('extensions')) {
2021-02-02 11:30:08 +00:00
try {
const packageJSON = JSON.parse(readFileSync(join('extensions', extension, 'package.json')).toString());
2021-02-02 11:30:08 +00:00
if (!(packageJSON && packageJSON.scripts && packageJSON.scripts['update-grammar'])) {
continue;
}
} catch {
continue;
}
2017-05-25 09:27:32 +00:00
2021-02-02 11:30:08 +00:00
await spawn(`npm`, ['run', 'update-grammar'], { cwd: `extensions/${extension}` });
}
2017-05-25 09:27:32 +00:00
2021-02-02 11:30:08 +00:00
// run integration tests
2017-05-25 09:27:32 +00:00
2021-02-02 11:30:08 +00:00
if (process.platform === 'win32') {
_spawn('.\\scripts\\test-integration.bat', [], { env: process.env, stdio: 'inherit' });
2021-02-02 11:30:08 +00:00
} else {
_spawn('/bin/bash', ['./scripts/test-integration.sh'], { env: process.env, stdio: 'inherit' });
2021-02-02 11:30:08 +00:00
}
}
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
2021-02-02 11:30:08 +00:00
main().catch(err => {
console.error(err);
process.exit(1);
});
}