Skip to content

Commit 5c2f770

Browse files
authored
Remove unused cancellation from build (microsoft#50658)
1 parent 66fbf05 commit 5c2f770

File tree

4 files changed

+14
-73
lines changed

4 files changed

+14
-73
lines changed

package-lock.json

Lines changed: 0 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
"mocha-fivemat-progress-reporter": "latest",
9191
"ms": "^2.1.3",
9292
"node-fetch": "^2.6.7",
93-
"prex": "^0.4.7",
9493
"source-map-support": "latest",
9594
"typescript": "^4.8.2",
9695
"vinyl": "latest",

scripts/build/tests.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const path = require("path");
66
const mkdirP = require("mkdirp");
77
const log = require("fancy-log");
88
const cmdLineOptions = require("./options");
9-
const { CancellationToken } = require("prex");
109
const { exec } = require("./utils");
1110
const { findUpFile } = require("./findUpDir");
1211

@@ -22,9 +21,8 @@ exports.localTest262Baseline = "internal/baselines/test262/local";
2221
* @param {string} defaultReporter
2322
* @param {boolean} runInParallel
2423
* @param {boolean} watchMode
25-
* @param {import("prex").CancellationToken} [cancelToken]
2624
*/
27-
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken = CancellationToken.none) {
25+
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode) {
2826
let testTimeout = cmdLineOptions.timeout;
2927
const tests = cmdLineOptions.tests;
3028
const inspect = cmdLineOptions.break || cmdLineOptions.inspect;
@@ -38,7 +36,6 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
3836
const shardId = +cmdLineOptions.shardId || undefined;
3937
if (!cmdLineOptions.dirty) {
4038
await cleanTestDirs();
41-
cancelToken.throwIfCancellationRequested();
4239
}
4340

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

122119
try {
123120
setNodeEnvToDevelopment();
124-
const { exitCode } = await exec(process.execPath, args, {
125-
cancelToken,
126-
});
121+
const { exitCode } = await exec(process.execPath, args);
127122
if (exitCode !== 0) {
128123
errorStatus = exitCode;
129124
error = new Error(`Process exited with status code ${errorStatus}.`);
@@ -132,8 +127,8 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
132127
// finally, do a sanity check and build the compiler with the built version of itself
133128
log.info("Starting sanity check build...");
134129
// Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
135-
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"], { cancelToken });
136-
const { exitCode } = await exec("gulp", ["local", "--lkg=false"], { cancelToken });
130+
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]);
131+
const { exitCode } = await exec("gulp", ["local", "--lkg=false"]);
137132
if (exitCode !== 0) {
138133
errorStatus = exitCode;
139134
error = new Error(`Sanity check build process exited with status code ${errorStatus}.`);

scripts/build/utils.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const ts = require("../../lib/typescript");
1414
const chalk = require("chalk");
1515
const which = require("which");
1616
const { spawn } = require("child_process");
17-
const { CancellationToken, CancelError, Deferred } = require("prex");
1817
const { Readable, Duplex } = require("stream");
1918

2019
/**
@@ -25,26 +24,17 @@ const { Readable, Duplex } = require("stream");
2524
*
2625
* @typedef ExecOptions
2726
* @property {boolean} [ignoreExitCode]
28-
* @property {import("prex").CancellationToken} [cancelToken]
2927
* @property {boolean} [hidePrompt]
3028
* @property {boolean} [waitForExit=true]
3129
*/
3230
async function exec(cmd, args, options = {}) {
3331
return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => {
34-
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
35-
cancelToken.throwIfCancellationRequested();
32+
const { ignoreExitCode, waitForExit = true } = options;
3633

3734
if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
3835
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
39-
const registration = cancelToken.register(() => {
40-
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
41-
proc.kill("SIGINT");
42-
proc.kill("SIGTERM");
43-
reject(new CancelError());
44-
});
4536
if (waitForExit) {
4637
proc.on("exit", exitCode => {
47-
registration.unregister();
4838
if (exitCode === 0 || ignoreExitCode) {
4939
resolve({ exitCode });
5040
}
@@ -53,7 +43,6 @@ async function exec(cmd, args, options = {}) {
5343
}
5444
});
5545
proc.on("error", error => {
56-
registration.unregister();
5746
reject(error);
5847
});
5948
}
@@ -395,6 +384,15 @@ function rm(dest, opts) {
395384
}
396385
exports.rm = rm;
397386

387+
class Deferred {
388+
constructor() {
389+
this.promise = new Promise((resolve, reject) => {
390+
this.resolve = resolve;
391+
this.reject = reject;
392+
});
393+
}
394+
}
395+
398396
class Debouncer {
399397
/**
400398
* @param {number} timeout

0 commit comments

Comments
 (0)