mirror of
https://github.com/Microsoft/vscode
synced 2024-08-24 19:46:05 +00:00
Experiment with using mjs for one of our build scripts
This commit is contained in:
parent
d6d2122c50
commit
fb1af79c7d
|
@ -2,14 +2,15 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
//@ts-check
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
import { spawn as _spawn } from 'child_process';
|
||||
import { readdirSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import url from 'url'
|
||||
|
||||
async function spawn(cmd, args, opts) {
|
||||
return new Promise((c, e) => {
|
||||
const child = cp.spawn(cmd, args, { shell: true, stdio: 'inherit', env: process.env, ...opts });
|
||||
const child = _spawn(cmd, args, { shell: true, stdio: 'inherit', env: process.env, ...opts });
|
||||
child.on('close', code => code === 0 ? c() : e(`Returned ${code}`));
|
||||
});
|
||||
}
|
||||
|
@ -17,9 +18,9 @@ async function spawn(cmd, args, opts) {
|
|||
async function main() {
|
||||
await spawn('yarn', [], { cwd: 'extensions' });
|
||||
|
||||
for (const extension of fs.readdirSync('extensions')) {
|
||||
for (const extension of readdirSync('extensions')) {
|
||||
try {
|
||||
let packageJSON = JSON.parse(fs.readFileSync(path.join('extensions', extension, 'package.json')).toString());
|
||||
let packageJSON = JSON.parse(readFileSync(join('extensions', extension, 'package.json')).toString());
|
||||
if (!(packageJSON && packageJSON.scripts && packageJSON.scripts['update-grammar'])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -33,13 +34,13 @@ async function main() {
|
|||
// run integration tests
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
cp.spawn('.\\scripts\\test-integration.bat', [], { env: process.env, stdio: 'inherit' });
|
||||
_spawn('.\\scripts\\test-integration.bat', [], { env: process.env, stdio: 'inherit' });
|
||||
} else {
|
||||
cp.spawn('/bin/bash', ['./scripts/test-integration.sh'], { env: process.env, stdio: 'inherit' });
|
||||
_spawn('/bin/bash', ['./scripts/test-integration.sh'], { env: process.env, stdio: 'inherit' });
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
|
@ -33,7 +33,7 @@
|
|||
"gulp": "node --max_old_space_size=8192 ./node_modules/gulp/bin/gulp.js",
|
||||
"electron": "node build/lib/electron",
|
||||
"7z": "7z",
|
||||
"update-grammars": "node build/npm/update-all-grammars.js",
|
||||
"update-grammars": "node build/npm/update-all-grammars.mjs",
|
||||
"update-localization-extension": "node build/npm/update-localization-extension.js",
|
||||
"smoketest": "node build/lib/preLaunch.js && cd test/smoke && yarn compile && node test/index.js",
|
||||
"smoketest-no-compile": "cd test/smoke && node test/index.js",
|
||||
|
|
Loading…
Reference in a new issue