mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Fix to use promise and remove unnecessary variables
This commit is contained in:
parent
01b6fa5b2e
commit
2b3444b493
1 changed files with 51 additions and 27 deletions
|
|
@ -1,13 +1,16 @@
|
||||||
import { spawnSync } from "child_process";
|
import { spawn } from "child_process";
|
||||||
import { globSync } from "glob";
|
import { globSync } from "glob";
|
||||||
import { exit } from "process";
|
import { exit } from "process";
|
||||||
|
|
||||||
|
(async () => {
|
||||||
let someFileError = false;
|
let someFileError = false;
|
||||||
const files = globSync("src/website/data/playground-samples/*/*/*.js");
|
const files = globSync("src/website/data/playground-samples/*/*/*.js");
|
||||||
|
type Result = { file: string; status: number; stdout: string };
|
||||||
|
const promises: Promise<Result>[] = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const command = `yarn tsc --noEmit --allowJs --checkJs --skipLibCheck ../out/monaco-editor/monaco.d.ts ${file}`;
|
promises.push(
|
||||||
console.log(file);
|
new Promise<Result>((resolve) => {
|
||||||
const { status, stdout } = spawnSync(
|
const process = spawn(
|
||||||
"yarn",
|
"yarn",
|
||||||
[
|
[
|
||||||
"tsc",
|
"tsc",
|
||||||
|
|
@ -20,8 +23,28 @@ for (const file of files) {
|
||||||
],
|
],
|
||||||
{ shell: true }
|
{ shell: true }
|
||||||
);
|
);
|
||||||
if (status != 0) {
|
let buffer = "";
|
||||||
console.log(stdout.toString());
|
process.on("exit", () => {
|
||||||
|
resolve({
|
||||||
|
file: file,
|
||||||
|
status: process.exitCode ?? 1,
|
||||||
|
stdout: buffer,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
process.stdout.on("data", (data) => {
|
||||||
|
buffer += data.toString();
|
||||||
|
});
|
||||||
|
process.stderr.on("data", (data) => {
|
||||||
|
buffer += data.toString();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (const promise of promises) {
|
||||||
|
const result = await promise;
|
||||||
|
console.log(result.file);
|
||||||
|
if (result.status != 0) {
|
||||||
|
console.log(result.stdout.toString());
|
||||||
someFileError = true;
|
someFileError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,3 +53,4 @@ if (someFileError) {
|
||||||
console.error("Some files had type errors.");
|
console.error("Some files had type errors.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue