diff --git a/package-lock.json b/package-lock.json index 7cc9dd1d949f2..42d270e873251 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,7 +64,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", @@ -89,21 +88,6 @@ "node": "^14 || ^16 || ^17 || ^18" } }, - "node_modules/@esfx/cancelable": { - "version": "1.0.0-pre.33", - "resolved": "https://registry.npmjs.org/@esfx/cancelable/-/cancelable-1.0.0-pre.33.tgz", - "integrity": "sha512-W5DCyDDkH8y4iaolrW7U1Rf+BrHZOoEwuThHY5A2EJwJ4PauTS4yFV2wKorYmJhfDC13lsw6rdzrh/DRwjrBIA==", - "dev": true, - "dependencies": { - "@esfx/disposable": "^1.0.0-pre.33" - } - }, - "node_modules/@esfx/disposable": { - "version": "1.0.0-pre.33", - "resolved": "https://registry.npmjs.org/@esfx/disposable/-/disposable-1.0.0-pre.33.tgz", - "integrity": "sha512-esqBTgZAUY5P8BHNqOL8dTTAG2jLnX9iKKQiP6GI0DmVAOY9GHA86HGy6dabqbzLAaZh/KJgHXOu1krjx1O7Pw==", - "dev": true - }, "node_modules/@eslint/eslintrc": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz", @@ -6521,16 +6505,6 @@ "node": ">= 0.8" } }, - "node_modules/prex": { - "version": "0.4.7", - "resolved": "https://registry.npmjs.org/prex/-/prex-0.4.7.tgz", - "integrity": "sha512-ulhl3iyjmAW/GroRQJN4CG+pC6KJ+W+deNRBkEShQwe16wLP9k92+x6RmLJuLiVSGkbxhnAqHpGdJJCh3bRpUQ==", - "dev": true, - "dependencies": { - "@esfx/cancelable": "^1.0.0-pre.13", - "@esfx/disposable": "^1.0.0-pre.13" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -8572,21 +8546,6 @@ "jsdoc-type-pratt-parser": "~3.1.0" } }, - "@esfx/cancelable": { - "version": "1.0.0-pre.33", - "resolved": "https://registry.npmjs.org/@esfx/cancelable/-/cancelable-1.0.0-pre.33.tgz", - "integrity": "sha512-W5DCyDDkH8y4iaolrW7U1Rf+BrHZOoEwuThHY5A2EJwJ4PauTS4yFV2wKorYmJhfDC13lsw6rdzrh/DRwjrBIA==", - "dev": true, - "requires": { - "@esfx/disposable": "^1.0.0-pre.33" - } - }, - "@esfx/disposable": { - "version": "1.0.0-pre.33", - "resolved": "https://registry.npmjs.org/@esfx/disposable/-/disposable-1.0.0-pre.33.tgz", - "integrity": "sha512-esqBTgZAUY5P8BHNqOL8dTTAG2jLnX9iKKQiP6GI0DmVAOY9GHA86HGy6dabqbzLAaZh/KJgHXOu1krjx1O7Pw==", - "dev": true - }, "@eslint/eslintrc": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz", @@ -13606,16 +13565,6 @@ "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==", "dev": true }, - "prex": { - "version": "0.4.7", - "resolved": "https://registry.npmjs.org/prex/-/prex-0.4.7.tgz", - "integrity": "sha512-ulhl3iyjmAW/GroRQJN4CG+pC6KJ+W+deNRBkEShQwe16wLP9k92+x6RmLJuLiVSGkbxhnAqHpGdJJCh3bRpUQ==", - "dev": true, - "requires": { - "@esfx/cancelable": "^1.0.0-pre.13", - "@esfx/disposable": "^1.0.0-pre.13" - } - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index da018f3c4263c..6ad6f556ae6a0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 5c804035ed08c..be5592faf8a1d 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -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"); @@ -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; @@ -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)) { @@ -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}.`); @@ -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}.`); diff --git a/scripts/build/utils.js b/scripts/build/utils.js index 6dcccec02f47e..0e38a0b73d6cf 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -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"); /** @@ -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 }); } @@ -53,7 +43,6 @@ async function exec(cmd, args, options = {}) { } }); proc.on("error", error => { - registration.unregister(); reject(error); }); } @@ -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