Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"mocha-fivemat-progress-reporter": "latest",
"ms": "^2.1.3",
"node-fetch": "^2.6.7",
"prex": "^0.4.7",
"source-map-support": "latest",
"typescript": "^4.8.2",
"vinyl": "latest",
Expand Down
13 changes: 4 additions & 9 deletions scripts/build/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const path = require("path");
const mkdirP = require("mkdirp");
const log = require("fancy-log");
const cmdLineOptions = require("./options");
const { CancellationToken } = require("prex");
const { exec } = require("./utils");
const { findUpFile } = require("./findUpDir");

Expand All @@ -22,9 +21,8 @@ exports.localTest262Baseline = "internal/baselines/test262/local";
* @param {string} defaultReporter
* @param {boolean} runInParallel
* @param {boolean} watchMode
* @param {import("prex").CancellationToken} [cancelToken]
*/
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken = CancellationToken.none) {
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode) {
let testTimeout = cmdLineOptions.timeout;
const tests = cmdLineOptions.tests;
const inspect = cmdLineOptions.break || cmdLineOptions.inspect;
Expand All @@ -38,7 +36,6 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
const shardId = +cmdLineOptions.shardId || undefined;
if (!cmdLineOptions.dirty) {
await cleanTestDirs();
cancelToken.throwIfCancellationRequested();
}

if (fs.existsSync(testConfigFile)) {
Expand Down Expand Up @@ -121,9 +118,7 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,

try {
setNodeEnvToDevelopment();
const { exitCode } = await exec(process.execPath, args, {
cancelToken,
});
const { exitCode } = await exec(process.execPath, args);
if (exitCode !== 0) {
errorStatus = exitCode;
error = new Error(`Process exited with status code ${errorStatus}.`);
Expand All @@ -132,8 +127,8 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
// finally, do a sanity check and build the compiler with the built version of itself
log.info("Starting sanity check build...");
// Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"], { cancelToken });
const { exitCode } = await exec("gulp", ["local", "--lkg=false"], { cancelToken });
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]);
const { exitCode } = await exec("gulp", ["local", "--lkg=false"]);
if (exitCode !== 0) {
errorStatus = exitCode;
error = new Error(`Sanity check build process exited with status code ${errorStatus}.`);
Expand Down
22 changes: 10 additions & 12 deletions scripts/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ts = require("../../lib/typescript");
const chalk = require("chalk");
const which = require("which");
const { spawn } = require("child_process");
const { CancellationToken, CancelError, Deferred } = require("prex");
const { Readable, Duplex } = require("stream");

/**
Expand All @@ -25,26 +24,17 @@ const { Readable, Duplex } = require("stream");
*
* @typedef ExecOptions
* @property {boolean} [ignoreExitCode]
* @property {import("prex").CancellationToken} [cancelToken]
* @property {boolean} [hidePrompt]
* @property {boolean} [waitForExit=true]
*/
async function exec(cmd, args, options = {}) {
return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => {
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
cancelToken.throwIfCancellationRequested();
const { ignoreExitCode, waitForExit = true } = options;

if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
const registration = cancelToken.register(() => {
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
proc.kill("SIGINT");
proc.kill("SIGTERM");
reject(new CancelError());
});
if (waitForExit) {
proc.on("exit", exitCode => {
registration.unregister();
if (exitCode === 0 || ignoreExitCode) {
resolve({ exitCode });
}
Expand All @@ -53,7 +43,6 @@ async function exec(cmd, args, options = {}) {
}
});
proc.on("error", error => {
registration.unregister();
reject(error);
});
}
Expand Down Expand Up @@ -395,6 +384,15 @@ function rm(dest, opts) {
}
exports.rm = rm;

class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
}

class Debouncer {
/**
* @param {number} timeout
Expand Down