vitest 0.18.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +5 -5
- package/dist/browser.d.ts +1890 -0
- package/dist/browser.mjs +22 -0
- package/dist/{chunk-api-setup.9d3f7670.mjs → chunk-api-setup.7c4c8879.mjs} +24 -6
- package/dist/{chunk-constants.d4406290.mjs → chunk-constants.16825f0c.mjs} +5 -4
- package/dist/{chunk-env-node.bbba78e5.mjs → chunk-defaults.1c51d585.mjs} +461 -457
- package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
- package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
- package/dist/{chunk-utils-global.0a7416cf.mjs → chunk-mock-date.9160e13b.mjs} +16 -41
- package/dist/chunk-node-git.43dbdd42.mjs +1139 -0
- package/dist/chunk-runtime-chain.b6c2cdbc.mjs +2041 -0
- package/dist/chunk-runtime-error.0aa0dc06.mjs +648 -0
- package/dist/{chunk-runtime-chain.b60d57da.mjs → chunk-runtime-hooks.3ee34848.mjs} +14 -2014
- package/dist/{chunk-runtime-mocker.1d853e3a.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
- package/dist/{chunk-runtime-rpc.9d1f4c48.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
- package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
- package/dist/{chunk-utils-source-map.c03f8bc4.mjs → chunk-utils-source-map.8198ebd9.mjs} +2 -2
- package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
- package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
- package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
- package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.2e90dadf.mjs} +165 -1182
- package/dist/{chunk-vite-node-utils.8077cd3c.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -312
- package/dist/cli.mjs +10 -10
- package/dist/config.cjs +6 -3
- package/dist/config.d.ts +2 -0
- package/dist/config.mjs +6 -3
- package/dist/entry.mjs +17 -598
- package/dist/index.d.ts +81 -6
- package/dist/index.mjs +10 -5
- package/dist/loader.mjs +35 -0
- package/dist/node.d.ts +71 -4
- package/dist/node.mjs +13 -12
- package/dist/suite.mjs +15 -0
- package/dist/vendor-index.61438b77.mjs +335 -0
- package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
- package/dist/worker.mjs +9 -6
- package/package.json +12 -4
- package/dist/chunk-integrations-globals.00b6e1ad.mjs +0 -23
package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.2e90dadf.mjs}
RENAMED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import {
|
|
1
|
+
import { j as join, z as basename, d as dirname, y as resolve, A as AggregateErrorPonyfill, p as picocolors, B as isAbsolute, C as relative, s as slash$2, l as isNode, o as relativePath, D as getTests, e as getFullName, x as hasFailed, E as hasFailedSnapshot, F as getSuites, v as shuffle, t as toArray$1, G as normalize, n as noop$1, H as deepMerge, I as toNamespacedPath, g as getCallLastIndex, f as notNullish, J as ensurePackageInstalled, K as stdout } from './chunk-mock-date.9160e13b.mjs';
|
|
2
|
+
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.1c51d585.mjs';
|
|
3
3
|
import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
|
|
4
4
|
import path$a from 'path';
|
|
5
|
-
import
|
|
5
|
+
import _url, { fileURLToPath } from 'url';
|
|
6
6
|
import process$1 from 'process';
|
|
7
7
|
import fs$8, { promises, existsSync, readFileSync } from 'fs';
|
|
8
|
-
import { d as distDir, c as configFiles, a as defaultPort } from './chunk-constants.
|
|
9
|
-
import require$$0, { cpus, hostname
|
|
10
|
-
import
|
|
11
|
-
import require$$0$
|
|
8
|
+
import { d as distDir, r as rootDir, c as configFiles, a as defaultPort } from './chunk-constants.16825f0c.mjs';
|
|
9
|
+
import require$$0, { cpus, hostname } from 'os';
|
|
10
|
+
import util$2 from 'util';
|
|
11
|
+
import require$$0$1 from 'stream';
|
|
12
12
|
import require$$2 from 'events';
|
|
13
13
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.a247c2c2.mjs';
|
|
15
15
|
import createDebug from 'debug';
|
|
16
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.9dfd1e3f.mjs';
|
|
16
17
|
import { MessageChannel } from 'worker_threads';
|
|
17
18
|
import { Tinypool } from 'tinypool';
|
|
18
19
|
import { performance } from 'perf_hooks';
|
|
19
|
-
import { c as stripAnsi, d as cliTruncate,
|
|
20
|
+
import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, e as stringWidth, h as ansiStyles, i as sliceAnsi, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.8198ebd9.mjs';
|
|
21
|
+
import { b as safeSetInterval, c as safeClearInterval, s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
20
22
|
import { resolveModule } from 'local-pkg';
|
|
21
23
|
import { createHash } from 'crypto';
|
|
22
|
-
import {
|
|
23
|
-
import childProcess from 'child_process';
|
|
24
|
-
import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.4bf9c627.mjs';
|
|
24
|
+
import { o as onetime, s as signalExit } from './vendor-index.61438b77.mjs';
|
|
25
25
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
26
|
-
import require$$0$
|
|
26
|
+
import require$$0$2 from 'readline';
|
|
27
27
|
import { p as prompts } from './vendor-index.de788b6a.mjs';
|
|
28
28
|
|
|
29
|
-
var version$1 = "0.
|
|
29
|
+
var version$1 = "0.20.0";
|
|
30
30
|
|
|
31
31
|
class EndError extends Error {
|
|
32
32
|
constructor(value) {
|
|
@@ -935,7 +935,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
935
935
|
* Licensed under the MIT License.
|
|
936
936
|
*/
|
|
937
937
|
|
|
938
|
-
const util$1 =
|
|
938
|
+
const util$1 = util$2;
|
|
939
939
|
const toRegexRange = toRegexRange_1;
|
|
940
940
|
|
|
941
941
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -3972,7 +3972,7 @@ var picomatch_1 = picomatch$1;
|
|
|
3972
3972
|
module.exports = picomatch_1;
|
|
3973
3973
|
} (picomatch$2));
|
|
3974
3974
|
|
|
3975
|
-
const util =
|
|
3975
|
+
const util = util$2;
|
|
3976
3976
|
const braces = braces_1;
|
|
3977
3977
|
const picomatch = picomatch$2.exports;
|
|
3978
3978
|
const utils$b = utils$f;
|
|
@@ -4616,7 +4616,7 @@ var stream$4 = {};
|
|
|
4616
4616
|
* Copyright (c) 2014-2020 Teambition
|
|
4617
4617
|
* Licensed under the MIT license.
|
|
4618
4618
|
*/
|
|
4619
|
-
const Stream = require$$0$
|
|
4619
|
+
const Stream = require$$0$1;
|
|
4620
4620
|
const PassThrough = Stream.PassThrough;
|
|
4621
4621
|
const slice = Array.prototype.slice;
|
|
4622
4622
|
|
|
@@ -5900,7 +5900,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
5900
5900
|
var stream$1 = {};
|
|
5901
5901
|
|
|
5902
5902
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
5903
|
-
const stream_1$5 = require$$0$
|
|
5903
|
+
const stream_1$5 = require$$0$1;
|
|
5904
5904
|
const async_1$2 = async$2;
|
|
5905
5905
|
class StreamProvider {
|
|
5906
5906
|
constructor(_root, _settings) {
|
|
@@ -6108,7 +6108,7 @@ class Reader {
|
|
|
6108
6108
|
reader.default = Reader;
|
|
6109
6109
|
|
|
6110
6110
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
6111
|
-
const stream_1$3 = require$$0$
|
|
6111
|
+
const stream_1$3 = require$$0$1;
|
|
6112
6112
|
const fsStat$1 = out$3;
|
|
6113
6113
|
const fsWalk$1 = out$2;
|
|
6114
6114
|
const reader_1$1 = reader;
|
|
@@ -6506,7 +6506,7 @@ async$6.default = ProviderAsync;
|
|
|
6506
6506
|
var stream = {};
|
|
6507
6507
|
|
|
6508
6508
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6509
|
-
const stream_1$1 = require$$0$
|
|
6509
|
+
const stream_1$1 = require$$0$1;
|
|
6510
6510
|
const stream_2 = stream$2;
|
|
6511
6511
|
const provider_1$1 = provider;
|
|
6512
6512
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -6739,7 +6739,7 @@ const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
|
6739
6739
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
6740
6740
|
const defaultInline = [
|
|
6741
6741
|
/virtual:/,
|
|
6742
|
-
/\.ts$/
|
|
6742
|
+
/\.[mc]?ts$/
|
|
6743
6743
|
];
|
|
6744
6744
|
const depsExternal = [
|
|
6745
6745
|
/\.cjs\.js$/,
|
|
@@ -6769,7 +6769,8 @@ function guessCJSversion(id) {
|
|
|
6769
6769
|
}
|
|
6770
6770
|
}
|
|
6771
6771
|
}
|
|
6772
|
-
|
|
6772
|
+
const _defaultExternalizeCache = /* @__PURE__ */ new Map();
|
|
6773
|
+
async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
|
|
6773
6774
|
if (!cache.has(id))
|
|
6774
6775
|
cache.set(id, _shouldExternalize(id, options));
|
|
6775
6776
|
return cache.get(id);
|
|
@@ -6830,6 +6831,7 @@ class ViteNodeServer {
|
|
|
6830
6831
|
this.fetchPromiseMap = /* @__PURE__ */ new Map();
|
|
6831
6832
|
this.transformPromiseMap = /* @__PURE__ */ new Map();
|
|
6832
6833
|
this.fetchCache = /* @__PURE__ */ new Map();
|
|
6834
|
+
this.externalizeCache = /* @__PURE__ */ new Map();
|
|
6833
6835
|
var _a, _b;
|
|
6834
6836
|
const ssrOptions = server.config.ssr;
|
|
6835
6837
|
if (ssrOptions) {
|
|
@@ -6841,9 +6843,17 @@ class ViteNodeServer {
|
|
|
6841
6843
|
options.deps.inline.push(...toArray(ssrOptions.noExternal));
|
|
6842
6844
|
}
|
|
6843
6845
|
}
|
|
6846
|
+
if (process.env.VITE_NODE_DEBUG_DUMP) {
|
|
6847
|
+
options.debug = Object.assign({
|
|
6848
|
+
dumpModules: !!process.env.VITE_NODE_DEBUG_DUMP,
|
|
6849
|
+
loadDumppedModules: process.env.VITE_NODE_DEBUG_DUMP === "load"
|
|
6850
|
+
}, options.debug ?? {});
|
|
6851
|
+
}
|
|
6852
|
+
if (options.debug)
|
|
6853
|
+
import('./chunk-vite-node-debug.c5887932.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
|
|
6844
6854
|
}
|
|
6845
6855
|
shouldExternalize(id) {
|
|
6846
|
-
return shouldExternalize(id, this.options.deps);
|
|
6856
|
+
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
|
6847
6857
|
}
|
|
6848
6858
|
async resolveId(id, importer) {
|
|
6849
6859
|
if (importer && !importer.startsWith(this.server.config.root))
|
|
@@ -6881,6 +6891,7 @@ class ViteNodeServer {
|
|
|
6881
6891
|
return "web";
|
|
6882
6892
|
}
|
|
6883
6893
|
async _fetchModule(id) {
|
|
6894
|
+
var _a;
|
|
6884
6895
|
let result;
|
|
6885
6896
|
const filePath = toFilePath(id, this.server.config.root);
|
|
6886
6897
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
@@ -6891,6 +6902,7 @@ class ViteNodeServer {
|
|
|
6891
6902
|
const externalize = await this.shouldExternalize(filePath);
|
|
6892
6903
|
if (externalize) {
|
|
6893
6904
|
result = { externalize };
|
|
6905
|
+
(_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
|
|
6894
6906
|
} else {
|
|
6895
6907
|
const r = await this._transformRequest(id);
|
|
6896
6908
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
@@ -6902,8 +6914,14 @@ class ViteNodeServer {
|
|
|
6902
6914
|
return result;
|
|
6903
6915
|
}
|
|
6904
6916
|
async _transformRequest(id) {
|
|
6917
|
+
var _a, _b, _c, _d;
|
|
6905
6918
|
debugRequest(id);
|
|
6906
6919
|
let result = null;
|
|
6920
|
+
if ((_a = this.options.debug) == null ? void 0 : _a.loadDumppedModules) {
|
|
6921
|
+
result = await ((_b = this.debugger) == null ? void 0 : _b.loadDump(id)) ?? null;
|
|
6922
|
+
if (result)
|
|
6923
|
+
return result;
|
|
6924
|
+
}
|
|
6907
6925
|
if (this.getTransformMode(id) === "web") {
|
|
6908
6926
|
result = await this.server.transformRequest(id);
|
|
6909
6927
|
if (result)
|
|
@@ -6914,6 +6932,8 @@ class ViteNodeServer {
|
|
|
6914
6932
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
6915
6933
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
6916
6934
|
withInlineSourcemap(result);
|
|
6935
|
+
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
6936
|
+
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
6917
6937
|
return result;
|
|
6918
6938
|
}
|
|
6919
6939
|
}
|
|
@@ -6980,17 +7000,27 @@ function addSnapshotResult(summary, result) {
|
|
|
6980
7000
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
6981
7001
|
}
|
|
6982
7002
|
|
|
6983
|
-
const workerPath = pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
7003
|
+
const workerPath = _url.pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
7004
|
+
const loaderPath = _url.pathToFileURL(resolve(distDir, "./loader.mjs")).href;
|
|
7005
|
+
const suppressLoaderWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
6984
7006
|
function createPool(ctx) {
|
|
6985
|
-
var _a;
|
|
7007
|
+
var _a, _b;
|
|
6986
7008
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
|
|
6987
7009
|
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
6988
7010
|
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7011
|
+
const conditions = (_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["-C", c]);
|
|
6989
7012
|
const options = {
|
|
6990
7013
|
filename: workerPath,
|
|
6991
7014
|
useAtomics: false,
|
|
6992
7015
|
maxThreads,
|
|
6993
|
-
minThreads
|
|
7016
|
+
minThreads,
|
|
7017
|
+
execArgv: [
|
|
7018
|
+
"--require",
|
|
7019
|
+
suppressLoaderWarningsPath,
|
|
7020
|
+
"--experimental-loader",
|
|
7021
|
+
loaderPath,
|
|
7022
|
+
...conditions || []
|
|
7023
|
+
]
|
|
6994
7024
|
};
|
|
6995
7025
|
if (ctx.config.isolate) {
|
|
6996
7026
|
options.isolateWorkers = true;
|
|
@@ -7002,7 +7032,7 @@ function createPool(ctx) {
|
|
|
7002
7032
|
options.minThreads = 1;
|
|
7003
7033
|
}
|
|
7004
7034
|
if (ctx.config.coverage.enabled)
|
|
7005
|
-
(
|
|
7035
|
+
(_b = process.env).NODE_V8_COVERAGE || (_b.NODE_V8_COVERAGE = ctx.config.coverage.tempDirectory);
|
|
7006
7036
|
options.env = {
|
|
7007
7037
|
TEST: "true",
|
|
7008
7038
|
VITEST: "true",
|
|
@@ -7084,6 +7114,10 @@ function createChannel(ctx) {
|
|
|
7084
7114
|
resolveId(id, importer) {
|
|
7085
7115
|
return ctx.vitenode.resolveId(id, importer);
|
|
7086
7116
|
},
|
|
7117
|
+
onPathsCollected(paths) {
|
|
7118
|
+
ctx.state.collectPaths(paths);
|
|
7119
|
+
ctx.report("onPathsCollected", paths);
|
|
7120
|
+
},
|
|
7087
7121
|
onCollected(files) {
|
|
7088
7122
|
ctx.state.collectFiles(files);
|
|
7089
7123
|
ctx.report("onCollected", files);
|
|
@@ -7287,13 +7321,14 @@ class BaseReporter {
|
|
|
7287
7321
|
this.start = performance.now();
|
|
7288
7322
|
}
|
|
7289
7323
|
relative(path) {
|
|
7290
|
-
return
|
|
7324
|
+
return relativePath(this.ctx.config.root, path);
|
|
7291
7325
|
}
|
|
7292
7326
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
7293
7327
|
this.end = performance.now();
|
|
7294
7328
|
await this.reportSummary(files);
|
|
7295
7329
|
if (errors.length) {
|
|
7296
|
-
|
|
7330
|
+
if (!this.ctx.config.dangerouslyIgnoreUnhandledErrors)
|
|
7331
|
+
process.exitCode = 1;
|
|
7297
7332
|
this.ctx.logger.printUnhandledErrors(errors);
|
|
7298
7333
|
}
|
|
7299
7334
|
}
|
|
@@ -7440,10 +7475,13 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7440
7475
|
await this.printTaskErrors(failedTests, errorDivider);
|
|
7441
7476
|
}
|
|
7442
7477
|
const executionTime = this.end - this.start;
|
|
7443
|
-
const
|
|
7478
|
+
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
7479
|
+
const setupTime = files.reduce((acc, test) => acc + Math.max(0, test.setupDuration || 0), 0);
|
|
7480
|
+
const testsTime = files.reduce((acc, test) => {
|
|
7444
7481
|
var _a2;
|
|
7445
|
-
return acc + Math.max(0, ((_a2 = test.result) == null ? void 0 : _a2.duration) || 0)
|
|
7482
|
+
return acc + Math.max(0, ((_a2 = test.result) == null ? void 0 : _a2.duration) || 0);
|
|
7446
7483
|
}, 0);
|
|
7484
|
+
const threadTime = collectTime + testsTime + setupTime;
|
|
7447
7485
|
const padTitle = (str) => picocolors.exports.dim(`${str.padStart(10)} `);
|
|
7448
7486
|
const time = (time2) => {
|
|
7449
7487
|
if (time2 > 1e3)
|
|
@@ -7461,7 +7499,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7461
7499
|
if (this.watchFilters)
|
|
7462
7500
|
logger.log(padTitle("Time"), time(threadTime));
|
|
7463
7501
|
else
|
|
7464
|
-
logger.log(padTitle("Time"), time(executionTime) + picocolors.exports.gray(` (
|
|
7502
|
+
logger.log(padTitle("Time"), time(executionTime) + picocolors.exports.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
|
|
7465
7503
|
logger.log();
|
|
7466
7504
|
}
|
|
7467
7505
|
async printTaskErrors(tasks, errorDivider) {
|
|
@@ -7817,7 +7855,8 @@ class JsonReporter {
|
|
|
7817
7855
|
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
7818
7856
|
title: t.name,
|
|
7819
7857
|
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
7820
|
-
failureMessages: ((_d = (_c = t.result) == null ? void 0 : _c.error) == null ? void 0 : _d.message) == null ? [] : [t.result.error.message]
|
|
7858
|
+
failureMessages: ((_d = (_c = t.result) == null ? void 0 : _c.error) == null ? void 0 : _d.message) == null ? [] : [t.result.error.message],
|
|
7859
|
+
location: this.getFailureLocation(t)
|
|
7821
7860
|
};
|
|
7822
7861
|
});
|
|
7823
7862
|
if (tests2.some((t) => {
|
|
@@ -7870,6 +7909,18 @@ class JsonReporter {
|
|
|
7870
7909
|
this.ctx.logger.log(report);
|
|
7871
7910
|
}
|
|
7872
7911
|
}
|
|
7912
|
+
getFailureLocation(test) {
|
|
7913
|
+
var _a;
|
|
7914
|
+
const error = (_a = test.result) == null ? void 0 : _a.error;
|
|
7915
|
+
if (!error)
|
|
7916
|
+
return;
|
|
7917
|
+
const stack = parseStacktrace(error);
|
|
7918
|
+
const frame = stack[stack.length - 1];
|
|
7919
|
+
if (!frame)
|
|
7920
|
+
return;
|
|
7921
|
+
const pos = frame.sourcePos || frame;
|
|
7922
|
+
return { line: pos.line, column: pos.column };
|
|
7923
|
+
}
|
|
7873
7924
|
}
|
|
7874
7925
|
|
|
7875
7926
|
class VerboseReporter extends DefaultReporter {
|
|
@@ -8196,6 +8247,8 @@ function createReporters(reporterReferences, runner) {
|
|
|
8196
8247
|
class StateManager {
|
|
8197
8248
|
constructor() {
|
|
8198
8249
|
this.filesMap = /* @__PURE__ */ new Map();
|
|
8250
|
+
this.pathsSet = /* @__PURE__ */ new Set();
|
|
8251
|
+
this.collectingPromise = void 0;
|
|
8199
8252
|
this.idMap = /* @__PURE__ */ new Map();
|
|
8200
8253
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
8201
8254
|
this.errorsSet = /* @__PURE__ */ new Set();
|
|
@@ -8210,6 +8263,23 @@ class StateManager {
|
|
|
8210
8263
|
getUnhandledErrors() {
|
|
8211
8264
|
return Array.from(this.errorsSet.values());
|
|
8212
8265
|
}
|
|
8266
|
+
startCollectingPaths() {
|
|
8267
|
+
let _resolve;
|
|
8268
|
+
const promise = new Promise((resolve) => {
|
|
8269
|
+
_resolve = resolve;
|
|
8270
|
+
});
|
|
8271
|
+
this.collectingPromise = { promise, resolve: _resolve };
|
|
8272
|
+
}
|
|
8273
|
+
finishCollectingPaths() {
|
|
8274
|
+
var _a;
|
|
8275
|
+
(_a = this.collectingPromise) == null ? void 0 : _a.resolve();
|
|
8276
|
+
this.collectingPromise = void 0;
|
|
8277
|
+
}
|
|
8278
|
+
async getPaths() {
|
|
8279
|
+
var _a;
|
|
8280
|
+
await ((_a = this.collectingPromise) == null ? void 0 : _a.promise);
|
|
8281
|
+
return Array.from(this.pathsSet);
|
|
8282
|
+
}
|
|
8213
8283
|
getFiles(keys) {
|
|
8214
8284
|
if (keys)
|
|
8215
8285
|
return keys.map((key) => this.filesMap.get(key)).filter(Boolean);
|
|
@@ -8224,6 +8294,11 @@ class StateManager {
|
|
|
8224
8294
|
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
8225
8295
|
}).map((i) => i.filepath);
|
|
8226
8296
|
}
|
|
8297
|
+
collectPaths(paths = []) {
|
|
8298
|
+
paths.forEach((path) => {
|
|
8299
|
+
this.pathsSet.add(path);
|
|
8300
|
+
});
|
|
8301
|
+
}
|
|
8227
8302
|
collectFiles(files = []) {
|
|
8228
8303
|
files.forEach((file) => {
|
|
8229
8304
|
this.filesMap.set(file.filepath, file);
|
|
@@ -8430,7 +8505,7 @@ const extraInlineDeps = [
|
|
|
8430
8505
|
];
|
|
8431
8506
|
function resolveApiConfig(options) {
|
|
8432
8507
|
let api;
|
|
8433
|
-
if (options.ui && !options.api)
|
|
8508
|
+
if ((options.ui || options.browser) && !options.api)
|
|
8434
8509
|
api = { port: defaultPort };
|
|
8435
8510
|
else if (options.api === true)
|
|
8436
8511
|
api = { port: defaultPort };
|
|
@@ -8531,1126 +8606,6 @@ function resolveConfig(options, viteConfig) {
|
|
|
8531
8606
|
return resolved;
|
|
8532
8607
|
}
|
|
8533
8608
|
|
|
8534
|
-
function stripFinalNewline(input) {
|
|
8535
|
-
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
8536
|
-
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
|
|
8537
|
-
|
|
8538
|
-
if (input[input.length - 1] === LF) {
|
|
8539
|
-
input = input.slice(0, -1);
|
|
8540
|
-
}
|
|
8541
|
-
|
|
8542
|
-
if (input[input.length - 1] === CR) {
|
|
8543
|
-
input = input.slice(0, -1);
|
|
8544
|
-
}
|
|
8545
|
-
|
|
8546
|
-
return input;
|
|
8547
|
-
}
|
|
8548
|
-
|
|
8549
|
-
function pathKey(options = {}) {
|
|
8550
|
-
const {
|
|
8551
|
-
env = process.env,
|
|
8552
|
-
platform = process.platform
|
|
8553
|
-
} = options;
|
|
8554
|
-
|
|
8555
|
-
if (platform !== 'win32') {
|
|
8556
|
-
return 'PATH';
|
|
8557
|
-
}
|
|
8558
|
-
|
|
8559
|
-
return Object.keys(env).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
|
|
8560
|
-
}
|
|
8561
|
-
|
|
8562
|
-
function npmRunPath(options = {}) {
|
|
8563
|
-
const {
|
|
8564
|
-
cwd = process$1.cwd(),
|
|
8565
|
-
path: path_ = process$1.env[pathKey()],
|
|
8566
|
-
execPath = process$1.execPath,
|
|
8567
|
-
} = options;
|
|
8568
|
-
|
|
8569
|
-
let previous;
|
|
8570
|
-
const cwdString = cwd instanceof URL ? url.fileURLToPath(cwd) : cwd;
|
|
8571
|
-
let cwdPath = path$a.resolve(cwdString);
|
|
8572
|
-
const result = [];
|
|
8573
|
-
|
|
8574
|
-
while (previous !== cwdPath) {
|
|
8575
|
-
result.push(path$a.join(cwdPath, 'node_modules/.bin'));
|
|
8576
|
-
previous = cwdPath;
|
|
8577
|
-
cwdPath = path$a.resolve(cwdPath, '..');
|
|
8578
|
-
}
|
|
8579
|
-
|
|
8580
|
-
// Ensure the running `node` binary is used.
|
|
8581
|
-
result.push(path$a.resolve(cwdString, execPath, '..'));
|
|
8582
|
-
|
|
8583
|
-
return [...result, path_].join(path$a.delimiter);
|
|
8584
|
-
}
|
|
8585
|
-
|
|
8586
|
-
function npmRunPathEnv({env = process$1.env, ...options} = {}) {
|
|
8587
|
-
env = {...env};
|
|
8588
|
-
|
|
8589
|
-
const path = pathKey({env});
|
|
8590
|
-
options.path = env[path];
|
|
8591
|
-
env[path] = npmRunPath(options);
|
|
8592
|
-
|
|
8593
|
-
return env;
|
|
8594
|
-
}
|
|
8595
|
-
|
|
8596
|
-
const copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
8597
|
-
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
|
|
8598
|
-
// `Function#prototype` is non-writable and non-configurable so can never be modified.
|
|
8599
|
-
if (property === 'length' || property === 'prototype') {
|
|
8600
|
-
return;
|
|
8601
|
-
}
|
|
8602
|
-
|
|
8603
|
-
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
|
|
8604
|
-
if (property === 'arguments' || property === 'caller') {
|
|
8605
|
-
return;
|
|
8606
|
-
}
|
|
8607
|
-
|
|
8608
|
-
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
8609
|
-
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
8610
|
-
|
|
8611
|
-
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
8612
|
-
return;
|
|
8613
|
-
}
|
|
8614
|
-
|
|
8615
|
-
Object.defineProperty(to, property, fromDescriptor);
|
|
8616
|
-
};
|
|
8617
|
-
|
|
8618
|
-
// `Object.defineProperty()` throws if the property exists, is not configurable and either:
|
|
8619
|
-
// - one its descriptors is changed
|
|
8620
|
-
// - it is non-writable and its value is changed
|
|
8621
|
-
const canCopyProperty = function (toDescriptor, fromDescriptor) {
|
|
8622
|
-
return toDescriptor === undefined || toDescriptor.configurable || (
|
|
8623
|
-
toDescriptor.writable === fromDescriptor.writable &&
|
|
8624
|
-
toDescriptor.enumerable === fromDescriptor.enumerable &&
|
|
8625
|
-
toDescriptor.configurable === fromDescriptor.configurable &&
|
|
8626
|
-
(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)
|
|
8627
|
-
);
|
|
8628
|
-
};
|
|
8629
|
-
|
|
8630
|
-
const changePrototype = (to, from) => {
|
|
8631
|
-
const fromPrototype = Object.getPrototypeOf(from);
|
|
8632
|
-
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
8633
|
-
return;
|
|
8634
|
-
}
|
|
8635
|
-
|
|
8636
|
-
Object.setPrototypeOf(to, fromPrototype);
|
|
8637
|
-
};
|
|
8638
|
-
|
|
8639
|
-
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
|
|
8640
|
-
|
|
8641
|
-
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
|
|
8642
|
-
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
|
|
8643
|
-
|
|
8644
|
-
// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
|
|
8645
|
-
// We use `bind()` instead of a closure for the same reason.
|
|
8646
|
-
// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
|
|
8647
|
-
const changeToString = (to, from, name) => {
|
|
8648
|
-
const withName = name === '' ? '' : `with ${name.trim()}() `;
|
|
8649
|
-
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
8650
|
-
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
|
|
8651
|
-
Object.defineProperty(newToString, 'name', toStringName);
|
|
8652
|
-
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
|
|
8653
|
-
};
|
|
8654
|
-
|
|
8655
|
-
function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
|
|
8656
|
-
const {name} = to;
|
|
8657
|
-
|
|
8658
|
-
for (const property of Reflect.ownKeys(from)) {
|
|
8659
|
-
copyProperty(to, from, property, ignoreNonConfigurable);
|
|
8660
|
-
}
|
|
8661
|
-
|
|
8662
|
-
changePrototype(to, from);
|
|
8663
|
-
changeToString(to, from, name);
|
|
8664
|
-
|
|
8665
|
-
return to;
|
|
8666
|
-
}
|
|
8667
|
-
|
|
8668
|
-
const calledFunctions = new WeakMap();
|
|
8669
|
-
|
|
8670
|
-
const onetime = (function_, options = {}) => {
|
|
8671
|
-
if (typeof function_ !== 'function') {
|
|
8672
|
-
throw new TypeError('Expected a function');
|
|
8673
|
-
}
|
|
8674
|
-
|
|
8675
|
-
let returnValue;
|
|
8676
|
-
let callCount = 0;
|
|
8677
|
-
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
8678
|
-
|
|
8679
|
-
const onetime = function (...arguments_) {
|
|
8680
|
-
calledFunctions.set(onetime, ++callCount);
|
|
8681
|
-
|
|
8682
|
-
if (callCount === 1) {
|
|
8683
|
-
returnValue = function_.apply(this, arguments_);
|
|
8684
|
-
function_ = null;
|
|
8685
|
-
} else if (options.throw === true) {
|
|
8686
|
-
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
8687
|
-
}
|
|
8688
|
-
|
|
8689
|
-
return returnValue;
|
|
8690
|
-
};
|
|
8691
|
-
|
|
8692
|
-
mimicFunction(onetime, function_);
|
|
8693
|
-
calledFunctions.set(onetime, callCount);
|
|
8694
|
-
|
|
8695
|
-
return onetime;
|
|
8696
|
-
};
|
|
8697
|
-
|
|
8698
|
-
onetime.callCount = function_ => {
|
|
8699
|
-
if (!calledFunctions.has(function_)) {
|
|
8700
|
-
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
8701
|
-
}
|
|
8702
|
-
|
|
8703
|
-
return calledFunctions.get(function_);
|
|
8704
|
-
};
|
|
8705
|
-
|
|
8706
|
-
const getRealtimeSignals=function(){
|
|
8707
|
-
const length=SIGRTMAX-SIGRTMIN+1;
|
|
8708
|
-
return Array.from({length},getRealtimeSignal);
|
|
8709
|
-
};
|
|
8710
|
-
|
|
8711
|
-
const getRealtimeSignal=function(value,index){
|
|
8712
|
-
return {
|
|
8713
|
-
name:`SIGRT${index+1}`,
|
|
8714
|
-
number:SIGRTMIN+index,
|
|
8715
|
-
action:"terminate",
|
|
8716
|
-
description:"Application-specific signal (realtime)",
|
|
8717
|
-
standard:"posix"};
|
|
8718
|
-
|
|
8719
|
-
};
|
|
8720
|
-
|
|
8721
|
-
const SIGRTMIN=34;
|
|
8722
|
-
const SIGRTMAX=64;
|
|
8723
|
-
|
|
8724
|
-
const SIGNALS=[
|
|
8725
|
-
{
|
|
8726
|
-
name:"SIGHUP",
|
|
8727
|
-
number:1,
|
|
8728
|
-
action:"terminate",
|
|
8729
|
-
description:"Terminal closed",
|
|
8730
|
-
standard:"posix"},
|
|
8731
|
-
|
|
8732
|
-
{
|
|
8733
|
-
name:"SIGINT",
|
|
8734
|
-
number:2,
|
|
8735
|
-
action:"terminate",
|
|
8736
|
-
description:"User interruption with CTRL-C",
|
|
8737
|
-
standard:"ansi"},
|
|
8738
|
-
|
|
8739
|
-
{
|
|
8740
|
-
name:"SIGQUIT",
|
|
8741
|
-
number:3,
|
|
8742
|
-
action:"core",
|
|
8743
|
-
description:"User interruption with CTRL-\\",
|
|
8744
|
-
standard:"posix"},
|
|
8745
|
-
|
|
8746
|
-
{
|
|
8747
|
-
name:"SIGILL",
|
|
8748
|
-
number:4,
|
|
8749
|
-
action:"core",
|
|
8750
|
-
description:"Invalid machine instruction",
|
|
8751
|
-
standard:"ansi"},
|
|
8752
|
-
|
|
8753
|
-
{
|
|
8754
|
-
name:"SIGTRAP",
|
|
8755
|
-
number:5,
|
|
8756
|
-
action:"core",
|
|
8757
|
-
description:"Debugger breakpoint",
|
|
8758
|
-
standard:"posix"},
|
|
8759
|
-
|
|
8760
|
-
{
|
|
8761
|
-
name:"SIGABRT",
|
|
8762
|
-
number:6,
|
|
8763
|
-
action:"core",
|
|
8764
|
-
description:"Aborted",
|
|
8765
|
-
standard:"ansi"},
|
|
8766
|
-
|
|
8767
|
-
{
|
|
8768
|
-
name:"SIGIOT",
|
|
8769
|
-
number:6,
|
|
8770
|
-
action:"core",
|
|
8771
|
-
description:"Aborted",
|
|
8772
|
-
standard:"bsd"},
|
|
8773
|
-
|
|
8774
|
-
{
|
|
8775
|
-
name:"SIGBUS",
|
|
8776
|
-
number:7,
|
|
8777
|
-
action:"core",
|
|
8778
|
-
description:
|
|
8779
|
-
"Bus error due to misaligned, non-existing address or paging error",
|
|
8780
|
-
standard:"bsd"},
|
|
8781
|
-
|
|
8782
|
-
{
|
|
8783
|
-
name:"SIGEMT",
|
|
8784
|
-
number:7,
|
|
8785
|
-
action:"terminate",
|
|
8786
|
-
description:"Command should be emulated but is not implemented",
|
|
8787
|
-
standard:"other"},
|
|
8788
|
-
|
|
8789
|
-
{
|
|
8790
|
-
name:"SIGFPE",
|
|
8791
|
-
number:8,
|
|
8792
|
-
action:"core",
|
|
8793
|
-
description:"Floating point arithmetic error",
|
|
8794
|
-
standard:"ansi"},
|
|
8795
|
-
|
|
8796
|
-
{
|
|
8797
|
-
name:"SIGKILL",
|
|
8798
|
-
number:9,
|
|
8799
|
-
action:"terminate",
|
|
8800
|
-
description:"Forced termination",
|
|
8801
|
-
standard:"posix",
|
|
8802
|
-
forced:true},
|
|
8803
|
-
|
|
8804
|
-
{
|
|
8805
|
-
name:"SIGUSR1",
|
|
8806
|
-
number:10,
|
|
8807
|
-
action:"terminate",
|
|
8808
|
-
description:"Application-specific signal",
|
|
8809
|
-
standard:"posix"},
|
|
8810
|
-
|
|
8811
|
-
{
|
|
8812
|
-
name:"SIGSEGV",
|
|
8813
|
-
number:11,
|
|
8814
|
-
action:"core",
|
|
8815
|
-
description:"Segmentation fault",
|
|
8816
|
-
standard:"ansi"},
|
|
8817
|
-
|
|
8818
|
-
{
|
|
8819
|
-
name:"SIGUSR2",
|
|
8820
|
-
number:12,
|
|
8821
|
-
action:"terminate",
|
|
8822
|
-
description:"Application-specific signal",
|
|
8823
|
-
standard:"posix"},
|
|
8824
|
-
|
|
8825
|
-
{
|
|
8826
|
-
name:"SIGPIPE",
|
|
8827
|
-
number:13,
|
|
8828
|
-
action:"terminate",
|
|
8829
|
-
description:"Broken pipe or socket",
|
|
8830
|
-
standard:"posix"},
|
|
8831
|
-
|
|
8832
|
-
{
|
|
8833
|
-
name:"SIGALRM",
|
|
8834
|
-
number:14,
|
|
8835
|
-
action:"terminate",
|
|
8836
|
-
description:"Timeout or timer",
|
|
8837
|
-
standard:"posix"},
|
|
8838
|
-
|
|
8839
|
-
{
|
|
8840
|
-
name:"SIGTERM",
|
|
8841
|
-
number:15,
|
|
8842
|
-
action:"terminate",
|
|
8843
|
-
description:"Termination",
|
|
8844
|
-
standard:"ansi"},
|
|
8845
|
-
|
|
8846
|
-
{
|
|
8847
|
-
name:"SIGSTKFLT",
|
|
8848
|
-
number:16,
|
|
8849
|
-
action:"terminate",
|
|
8850
|
-
description:"Stack is empty or overflowed",
|
|
8851
|
-
standard:"other"},
|
|
8852
|
-
|
|
8853
|
-
{
|
|
8854
|
-
name:"SIGCHLD",
|
|
8855
|
-
number:17,
|
|
8856
|
-
action:"ignore",
|
|
8857
|
-
description:"Child process terminated, paused or unpaused",
|
|
8858
|
-
standard:"posix"},
|
|
8859
|
-
|
|
8860
|
-
{
|
|
8861
|
-
name:"SIGCLD",
|
|
8862
|
-
number:17,
|
|
8863
|
-
action:"ignore",
|
|
8864
|
-
description:"Child process terminated, paused or unpaused",
|
|
8865
|
-
standard:"other"},
|
|
8866
|
-
|
|
8867
|
-
{
|
|
8868
|
-
name:"SIGCONT",
|
|
8869
|
-
number:18,
|
|
8870
|
-
action:"unpause",
|
|
8871
|
-
description:"Unpaused",
|
|
8872
|
-
standard:"posix",
|
|
8873
|
-
forced:true},
|
|
8874
|
-
|
|
8875
|
-
{
|
|
8876
|
-
name:"SIGSTOP",
|
|
8877
|
-
number:19,
|
|
8878
|
-
action:"pause",
|
|
8879
|
-
description:"Paused",
|
|
8880
|
-
standard:"posix",
|
|
8881
|
-
forced:true},
|
|
8882
|
-
|
|
8883
|
-
{
|
|
8884
|
-
name:"SIGTSTP",
|
|
8885
|
-
number:20,
|
|
8886
|
-
action:"pause",
|
|
8887
|
-
description:"Paused using CTRL-Z or \"suspend\"",
|
|
8888
|
-
standard:"posix"},
|
|
8889
|
-
|
|
8890
|
-
{
|
|
8891
|
-
name:"SIGTTIN",
|
|
8892
|
-
number:21,
|
|
8893
|
-
action:"pause",
|
|
8894
|
-
description:"Background process cannot read terminal input",
|
|
8895
|
-
standard:"posix"},
|
|
8896
|
-
|
|
8897
|
-
{
|
|
8898
|
-
name:"SIGBREAK",
|
|
8899
|
-
number:21,
|
|
8900
|
-
action:"terminate",
|
|
8901
|
-
description:"User interruption with CTRL-BREAK",
|
|
8902
|
-
standard:"other"},
|
|
8903
|
-
|
|
8904
|
-
{
|
|
8905
|
-
name:"SIGTTOU",
|
|
8906
|
-
number:22,
|
|
8907
|
-
action:"pause",
|
|
8908
|
-
description:"Background process cannot write to terminal output",
|
|
8909
|
-
standard:"posix"},
|
|
8910
|
-
|
|
8911
|
-
{
|
|
8912
|
-
name:"SIGURG",
|
|
8913
|
-
number:23,
|
|
8914
|
-
action:"ignore",
|
|
8915
|
-
description:"Socket received out-of-band data",
|
|
8916
|
-
standard:"bsd"},
|
|
8917
|
-
|
|
8918
|
-
{
|
|
8919
|
-
name:"SIGXCPU",
|
|
8920
|
-
number:24,
|
|
8921
|
-
action:"core",
|
|
8922
|
-
description:"Process timed out",
|
|
8923
|
-
standard:"bsd"},
|
|
8924
|
-
|
|
8925
|
-
{
|
|
8926
|
-
name:"SIGXFSZ",
|
|
8927
|
-
number:25,
|
|
8928
|
-
action:"core",
|
|
8929
|
-
description:"File too big",
|
|
8930
|
-
standard:"bsd"},
|
|
8931
|
-
|
|
8932
|
-
{
|
|
8933
|
-
name:"SIGVTALRM",
|
|
8934
|
-
number:26,
|
|
8935
|
-
action:"terminate",
|
|
8936
|
-
description:"Timeout or timer",
|
|
8937
|
-
standard:"bsd"},
|
|
8938
|
-
|
|
8939
|
-
{
|
|
8940
|
-
name:"SIGPROF",
|
|
8941
|
-
number:27,
|
|
8942
|
-
action:"terminate",
|
|
8943
|
-
description:"Timeout or timer",
|
|
8944
|
-
standard:"bsd"},
|
|
8945
|
-
|
|
8946
|
-
{
|
|
8947
|
-
name:"SIGWINCH",
|
|
8948
|
-
number:28,
|
|
8949
|
-
action:"ignore",
|
|
8950
|
-
description:"Terminal window size changed",
|
|
8951
|
-
standard:"bsd"},
|
|
8952
|
-
|
|
8953
|
-
{
|
|
8954
|
-
name:"SIGIO",
|
|
8955
|
-
number:29,
|
|
8956
|
-
action:"terminate",
|
|
8957
|
-
description:"I/O is available",
|
|
8958
|
-
standard:"other"},
|
|
8959
|
-
|
|
8960
|
-
{
|
|
8961
|
-
name:"SIGPOLL",
|
|
8962
|
-
number:29,
|
|
8963
|
-
action:"terminate",
|
|
8964
|
-
description:"Watched event",
|
|
8965
|
-
standard:"other"},
|
|
8966
|
-
|
|
8967
|
-
{
|
|
8968
|
-
name:"SIGINFO",
|
|
8969
|
-
number:29,
|
|
8970
|
-
action:"ignore",
|
|
8971
|
-
description:"Request for process information",
|
|
8972
|
-
standard:"other"},
|
|
8973
|
-
|
|
8974
|
-
{
|
|
8975
|
-
name:"SIGPWR",
|
|
8976
|
-
number:30,
|
|
8977
|
-
action:"terminate",
|
|
8978
|
-
description:"Device running out of power",
|
|
8979
|
-
standard:"systemv"},
|
|
8980
|
-
|
|
8981
|
-
{
|
|
8982
|
-
name:"SIGSYS",
|
|
8983
|
-
number:31,
|
|
8984
|
-
action:"core",
|
|
8985
|
-
description:"Invalid system call",
|
|
8986
|
-
standard:"other"},
|
|
8987
|
-
|
|
8988
|
-
{
|
|
8989
|
-
name:"SIGUNUSED",
|
|
8990
|
-
number:31,
|
|
8991
|
-
action:"terminate",
|
|
8992
|
-
description:"Invalid system call",
|
|
8993
|
-
standard:"other"}];
|
|
8994
|
-
|
|
8995
|
-
const getSignals=function(){
|
|
8996
|
-
const realtimeSignals=getRealtimeSignals();
|
|
8997
|
-
const signals=[...SIGNALS,...realtimeSignals].map(normalizeSignal);
|
|
8998
|
-
return signals;
|
|
8999
|
-
};
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
const normalizeSignal=function({
|
|
9008
|
-
name,
|
|
9009
|
-
number:defaultNumber,
|
|
9010
|
-
description,
|
|
9011
|
-
action,
|
|
9012
|
-
forced=false,
|
|
9013
|
-
standard})
|
|
9014
|
-
{
|
|
9015
|
-
const{
|
|
9016
|
-
signals:{[name]:constantSignal}}=
|
|
9017
|
-
constants$5;
|
|
9018
|
-
const supported=constantSignal!==undefined;
|
|
9019
|
-
const number=supported?constantSignal:defaultNumber;
|
|
9020
|
-
return {name,number,description,supported,action,forced,standard};
|
|
9021
|
-
};
|
|
9022
|
-
|
|
9023
|
-
const getSignalsByName=function(){
|
|
9024
|
-
const signals=getSignals();
|
|
9025
|
-
return signals.reduce(getSignalByName,{});
|
|
9026
|
-
};
|
|
9027
|
-
|
|
9028
|
-
const getSignalByName=function(
|
|
9029
|
-
signalByNameMemo,
|
|
9030
|
-
{name,number,description,supported,action,forced,standard})
|
|
9031
|
-
{
|
|
9032
|
-
return {
|
|
9033
|
-
...signalByNameMemo,
|
|
9034
|
-
[name]:{name,number,description,supported,action,forced,standard}};
|
|
9035
|
-
|
|
9036
|
-
};
|
|
9037
|
-
|
|
9038
|
-
const signalsByName=getSignalsByName();
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
const getSignalsByNumber=function(){
|
|
9044
|
-
const signals=getSignals();
|
|
9045
|
-
const length=SIGRTMAX+1;
|
|
9046
|
-
const signalsA=Array.from({length},(value,number)=>
|
|
9047
|
-
getSignalByNumber(number,signals));
|
|
9048
|
-
|
|
9049
|
-
return Object.assign({},...signalsA);
|
|
9050
|
-
};
|
|
9051
|
-
|
|
9052
|
-
const getSignalByNumber=function(number,signals){
|
|
9053
|
-
const signal=findSignalByNumber(number,signals);
|
|
9054
|
-
|
|
9055
|
-
if(signal===undefined){
|
|
9056
|
-
return {};
|
|
9057
|
-
}
|
|
9058
|
-
|
|
9059
|
-
const{name,description,supported,action,forced,standard}=signal;
|
|
9060
|
-
return {
|
|
9061
|
-
[number]:{
|
|
9062
|
-
name,
|
|
9063
|
-
number,
|
|
9064
|
-
description,
|
|
9065
|
-
supported,
|
|
9066
|
-
action,
|
|
9067
|
-
forced,
|
|
9068
|
-
standard}};
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
};
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
const findSignalByNumber=function(number,signals){
|
|
9076
|
-
const signal=signals.find(({name})=>constants$5.signals[name]===number);
|
|
9077
|
-
|
|
9078
|
-
if(signal!==undefined){
|
|
9079
|
-
return signal;
|
|
9080
|
-
}
|
|
9081
|
-
|
|
9082
|
-
return signals.find((signalA)=>signalA.number===number);
|
|
9083
|
-
};
|
|
9084
|
-
|
|
9085
|
-
getSignalsByNumber();
|
|
9086
|
-
|
|
9087
|
-
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
|
|
9088
|
-
if (timedOut) {
|
|
9089
|
-
return `timed out after ${timeout} milliseconds`;
|
|
9090
|
-
}
|
|
9091
|
-
|
|
9092
|
-
if (isCanceled) {
|
|
9093
|
-
return 'was canceled';
|
|
9094
|
-
}
|
|
9095
|
-
|
|
9096
|
-
if (errorCode !== undefined) {
|
|
9097
|
-
return `failed with ${errorCode}`;
|
|
9098
|
-
}
|
|
9099
|
-
|
|
9100
|
-
if (signal !== undefined) {
|
|
9101
|
-
return `was killed with ${signal} (${signalDescription})`;
|
|
9102
|
-
}
|
|
9103
|
-
|
|
9104
|
-
if (exitCode !== undefined) {
|
|
9105
|
-
return `failed with exit code ${exitCode}`;
|
|
9106
|
-
}
|
|
9107
|
-
|
|
9108
|
-
return 'failed';
|
|
9109
|
-
};
|
|
9110
|
-
|
|
9111
|
-
const makeError = ({
|
|
9112
|
-
stdout,
|
|
9113
|
-
stderr,
|
|
9114
|
-
all,
|
|
9115
|
-
error,
|
|
9116
|
-
signal,
|
|
9117
|
-
exitCode,
|
|
9118
|
-
command,
|
|
9119
|
-
escapedCommand,
|
|
9120
|
-
timedOut,
|
|
9121
|
-
isCanceled,
|
|
9122
|
-
killed,
|
|
9123
|
-
parsed: {options: {timeout}},
|
|
9124
|
-
}) => {
|
|
9125
|
-
// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
|
|
9126
|
-
// We normalize them to `undefined`
|
|
9127
|
-
exitCode = exitCode === null ? undefined : exitCode;
|
|
9128
|
-
signal = signal === null ? undefined : signal;
|
|
9129
|
-
const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
|
|
9130
|
-
|
|
9131
|
-
const errorCode = error && error.code;
|
|
9132
|
-
|
|
9133
|
-
const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
|
|
9134
|
-
const execaMessage = `Command ${prefix}: ${command}`;
|
|
9135
|
-
const isError = Object.prototype.toString.call(error) === '[object Error]';
|
|
9136
|
-
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
|
|
9137
|
-
const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
|
|
9138
|
-
|
|
9139
|
-
if (isError) {
|
|
9140
|
-
error.originalMessage = error.message;
|
|
9141
|
-
error.message = message;
|
|
9142
|
-
} else {
|
|
9143
|
-
error = new Error(message);
|
|
9144
|
-
}
|
|
9145
|
-
|
|
9146
|
-
error.shortMessage = shortMessage;
|
|
9147
|
-
error.command = command;
|
|
9148
|
-
error.escapedCommand = escapedCommand;
|
|
9149
|
-
error.exitCode = exitCode;
|
|
9150
|
-
error.signal = signal;
|
|
9151
|
-
error.signalDescription = signalDescription;
|
|
9152
|
-
error.stdout = stdout;
|
|
9153
|
-
error.stderr = stderr;
|
|
9154
|
-
|
|
9155
|
-
if (all !== undefined) {
|
|
9156
|
-
error.all = all;
|
|
9157
|
-
}
|
|
9158
|
-
|
|
9159
|
-
if ('bufferedData' in error) {
|
|
9160
|
-
delete error.bufferedData;
|
|
9161
|
-
}
|
|
9162
|
-
|
|
9163
|
-
error.failed = true;
|
|
9164
|
-
error.timedOut = Boolean(timedOut);
|
|
9165
|
-
error.isCanceled = isCanceled;
|
|
9166
|
-
error.killed = killed && !timedOut;
|
|
9167
|
-
|
|
9168
|
-
return error;
|
|
9169
|
-
};
|
|
9170
|
-
|
|
9171
|
-
const aliases = ['stdin', 'stdout', 'stderr'];
|
|
9172
|
-
|
|
9173
|
-
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
|
|
9174
|
-
|
|
9175
|
-
const normalizeStdio = options => {
|
|
9176
|
-
if (!options) {
|
|
9177
|
-
return;
|
|
9178
|
-
}
|
|
9179
|
-
|
|
9180
|
-
const {stdio} = options;
|
|
9181
|
-
|
|
9182
|
-
if (stdio === undefined) {
|
|
9183
|
-
return aliases.map(alias => options[alias]);
|
|
9184
|
-
}
|
|
9185
|
-
|
|
9186
|
-
if (hasAlias(options)) {
|
|
9187
|
-
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
|
|
9188
|
-
}
|
|
9189
|
-
|
|
9190
|
-
if (typeof stdio === 'string') {
|
|
9191
|
-
return stdio;
|
|
9192
|
-
}
|
|
9193
|
-
|
|
9194
|
-
if (!Array.isArray(stdio)) {
|
|
9195
|
-
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|
9196
|
-
}
|
|
9197
|
-
|
|
9198
|
-
const length = Math.max(stdio.length, aliases.length);
|
|
9199
|
-
return Array.from({length}, (value, index) => stdio[index]);
|
|
9200
|
-
};
|
|
9201
|
-
|
|
9202
|
-
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|
9203
|
-
|
|
9204
|
-
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
|
|
9205
|
-
const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
|
|
9206
|
-
const killResult = kill(signal);
|
|
9207
|
-
setKillTimeout(kill, signal, options, killResult);
|
|
9208
|
-
return killResult;
|
|
9209
|
-
};
|
|
9210
|
-
|
|
9211
|
-
const setKillTimeout = (kill, signal, options, killResult) => {
|
|
9212
|
-
if (!shouldForceKill(signal, options, killResult)) {
|
|
9213
|
-
return;
|
|
9214
|
-
}
|
|
9215
|
-
|
|
9216
|
-
const timeout = getForceKillAfterTimeout(options);
|
|
9217
|
-
const t = setTimeout(() => {
|
|
9218
|
-
kill('SIGKILL');
|
|
9219
|
-
}, timeout);
|
|
9220
|
-
|
|
9221
|
-
// Guarded because there's no `.unref()` when `execa` is used in the renderer
|
|
9222
|
-
// process in Electron. This cannot be tested since we don't run tests in
|
|
9223
|
-
// Electron.
|
|
9224
|
-
// istanbul ignore else
|
|
9225
|
-
if (t.unref) {
|
|
9226
|
-
t.unref();
|
|
9227
|
-
}
|
|
9228
|
-
};
|
|
9229
|
-
|
|
9230
|
-
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
9231
|
-
|
|
9232
|
-
const isSigterm = signal => signal === require$$0.constants.signals.SIGTERM
|
|
9233
|
-
|| (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|
9234
|
-
|
|
9235
|
-
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|
|
9236
|
-
if (forceKillAfterTimeout === true) {
|
|
9237
|
-
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|
9238
|
-
}
|
|
9239
|
-
|
|
9240
|
-
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
|
|
9241
|
-
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
|
|
9242
|
-
}
|
|
9243
|
-
|
|
9244
|
-
return forceKillAfterTimeout;
|
|
9245
|
-
};
|
|
9246
|
-
|
|
9247
|
-
// `childProcess.cancel()`
|
|
9248
|
-
const spawnedCancel = (spawned, context) => {
|
|
9249
|
-
const killResult = spawned.kill();
|
|
9250
|
-
|
|
9251
|
-
if (killResult) {
|
|
9252
|
-
context.isCanceled = true;
|
|
9253
|
-
}
|
|
9254
|
-
};
|
|
9255
|
-
|
|
9256
|
-
const timeoutKill = (spawned, signal, reject) => {
|
|
9257
|
-
spawned.kill(signal);
|
|
9258
|
-
reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
|
|
9259
|
-
};
|
|
9260
|
-
|
|
9261
|
-
// `timeout` option handling
|
|
9262
|
-
const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
|
|
9263
|
-
if (timeout === 0 || timeout === undefined) {
|
|
9264
|
-
return spawnedPromise;
|
|
9265
|
-
}
|
|
9266
|
-
|
|
9267
|
-
let timeoutId;
|
|
9268
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
|
9269
|
-
timeoutId = setTimeout(() => {
|
|
9270
|
-
timeoutKill(spawned, killSignal, reject);
|
|
9271
|
-
}, timeout);
|
|
9272
|
-
});
|
|
9273
|
-
|
|
9274
|
-
const safeSpawnedPromise = spawnedPromise.finally(() => {
|
|
9275
|
-
clearTimeout(timeoutId);
|
|
9276
|
-
});
|
|
9277
|
-
|
|
9278
|
-
return Promise.race([timeoutPromise, safeSpawnedPromise]);
|
|
9279
|
-
};
|
|
9280
|
-
|
|
9281
|
-
const validateTimeout = ({timeout}) => {
|
|
9282
|
-
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
|
|
9283
|
-
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|
9284
|
-
}
|
|
9285
|
-
};
|
|
9286
|
-
|
|
9287
|
-
// `cleanup` option handling
|
|
9288
|
-
const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
|
|
9289
|
-
if (!cleanup || detached) {
|
|
9290
|
-
return timedPromise;
|
|
9291
|
-
}
|
|
9292
|
-
|
|
9293
|
-
const removeExitHandler = signalExit.exports(() => {
|
|
9294
|
-
spawned.kill();
|
|
9295
|
-
});
|
|
9296
|
-
|
|
9297
|
-
return timedPromise.finally(() => {
|
|
9298
|
-
removeExitHandler();
|
|
9299
|
-
});
|
|
9300
|
-
};
|
|
9301
|
-
|
|
9302
|
-
function isStream(stream) {
|
|
9303
|
-
return stream !== null
|
|
9304
|
-
&& typeof stream === 'object'
|
|
9305
|
-
&& typeof stream.pipe === 'function';
|
|
9306
|
-
}
|
|
9307
|
-
|
|
9308
|
-
// `input` option
|
|
9309
|
-
const handleInput = (spawned, input) => {
|
|
9310
|
-
// Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
|
|
9311
|
-
// @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
|
|
9312
|
-
if (input === undefined || spawned.stdin === undefined) {
|
|
9313
|
-
return;
|
|
9314
|
-
}
|
|
9315
|
-
|
|
9316
|
-
if (isStream(input)) {
|
|
9317
|
-
input.pipe(spawned.stdin);
|
|
9318
|
-
} else {
|
|
9319
|
-
spawned.stdin.end(input);
|
|
9320
|
-
}
|
|
9321
|
-
};
|
|
9322
|
-
|
|
9323
|
-
// `all` interleaves `stdout` and `stderr`
|
|
9324
|
-
const makeAllStream = (spawned, {all}) => {
|
|
9325
|
-
if (!all || (!spawned.stdout && !spawned.stderr)) {
|
|
9326
|
-
return;
|
|
9327
|
-
}
|
|
9328
|
-
|
|
9329
|
-
const mixed = mergeStream();
|
|
9330
|
-
|
|
9331
|
-
if (spawned.stdout) {
|
|
9332
|
-
mixed.add(spawned.stdout);
|
|
9333
|
-
}
|
|
9334
|
-
|
|
9335
|
-
if (spawned.stderr) {
|
|
9336
|
-
mixed.add(spawned.stderr);
|
|
9337
|
-
}
|
|
9338
|
-
|
|
9339
|
-
return mixed;
|
|
9340
|
-
};
|
|
9341
|
-
|
|
9342
|
-
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
|
|
9343
|
-
const getBufferedData = async (stream, streamPromise) => {
|
|
9344
|
-
if (!stream) {
|
|
9345
|
-
return;
|
|
9346
|
-
}
|
|
9347
|
-
|
|
9348
|
-
stream.destroy();
|
|
9349
|
-
|
|
9350
|
-
try {
|
|
9351
|
-
return await streamPromise;
|
|
9352
|
-
} catch (error) {
|
|
9353
|
-
return error.bufferedData;
|
|
9354
|
-
}
|
|
9355
|
-
};
|
|
9356
|
-
|
|
9357
|
-
const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
|
|
9358
|
-
if (!stream || !buffer) {
|
|
9359
|
-
return;
|
|
9360
|
-
}
|
|
9361
|
-
|
|
9362
|
-
if (encoding) {
|
|
9363
|
-
return getStream.exports(stream, {encoding, maxBuffer});
|
|
9364
|
-
}
|
|
9365
|
-
|
|
9366
|
-
return getStream.exports.buffer(stream, {maxBuffer});
|
|
9367
|
-
};
|
|
9368
|
-
|
|
9369
|
-
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
|
|
9370
|
-
const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
|
|
9371
|
-
const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
|
|
9372
|
-
const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
|
|
9373
|
-
const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
|
|
9374
|
-
|
|
9375
|
-
try {
|
|
9376
|
-
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
|
|
9377
|
-
} catch (error) {
|
|
9378
|
-
return Promise.all([
|
|
9379
|
-
{error, signal: error.signal, timedOut: error.timedOut},
|
|
9380
|
-
getBufferedData(stdout, stdoutPromise),
|
|
9381
|
-
getBufferedData(stderr, stderrPromise),
|
|
9382
|
-
getBufferedData(all, allPromise),
|
|
9383
|
-
]);
|
|
9384
|
-
}
|
|
9385
|
-
};
|
|
9386
|
-
|
|
9387
|
-
const nativePromisePrototype = (async () => {})().constructor.prototype;
|
|
9388
|
-
const descriptors = ['then', 'catch', 'finally'].map(property => [
|
|
9389
|
-
property,
|
|
9390
|
-
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property),
|
|
9391
|
-
]);
|
|
9392
|
-
|
|
9393
|
-
// The return value is a mixin of `childProcess` and `Promise`
|
|
9394
|
-
const mergePromise = (spawned, promise) => {
|
|
9395
|
-
for (const [property, descriptor] of descriptors) {
|
|
9396
|
-
// Starting the main `promise` is deferred to avoid consuming streams
|
|
9397
|
-
const value = typeof promise === 'function'
|
|
9398
|
-
? (...args) => Reflect.apply(descriptor.value, promise(), args)
|
|
9399
|
-
: descriptor.value.bind(promise);
|
|
9400
|
-
|
|
9401
|
-
Reflect.defineProperty(spawned, property, {...descriptor, value});
|
|
9402
|
-
}
|
|
9403
|
-
|
|
9404
|
-
return spawned;
|
|
9405
|
-
};
|
|
9406
|
-
|
|
9407
|
-
// Use promises instead of `child_process` events
|
|
9408
|
-
const getSpawnedPromise = spawned => new Promise((resolve, reject) => {
|
|
9409
|
-
spawned.on('exit', (exitCode, signal) => {
|
|
9410
|
-
resolve({exitCode, signal});
|
|
9411
|
-
});
|
|
9412
|
-
|
|
9413
|
-
spawned.on('error', error => {
|
|
9414
|
-
reject(error);
|
|
9415
|
-
});
|
|
9416
|
-
|
|
9417
|
-
if (spawned.stdin) {
|
|
9418
|
-
spawned.stdin.on('error', error => {
|
|
9419
|
-
reject(error);
|
|
9420
|
-
});
|
|
9421
|
-
}
|
|
9422
|
-
});
|
|
9423
|
-
|
|
9424
|
-
const normalizeArgs = (file, args = []) => {
|
|
9425
|
-
if (!Array.isArray(args)) {
|
|
9426
|
-
return [file];
|
|
9427
|
-
}
|
|
9428
|
-
|
|
9429
|
-
return [file, ...args];
|
|
9430
|
-
};
|
|
9431
|
-
|
|
9432
|
-
const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
|
|
9433
|
-
const DOUBLE_QUOTES_REGEXP = /"/g;
|
|
9434
|
-
|
|
9435
|
-
const escapeArg = arg => {
|
|
9436
|
-
if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
|
|
9437
|
-
return arg;
|
|
9438
|
-
}
|
|
9439
|
-
|
|
9440
|
-
return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
|
|
9441
|
-
};
|
|
9442
|
-
|
|
9443
|
-
const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
|
|
9444
|
-
|
|
9445
|
-
const getEscapedCommand = (file, args) => normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
|
|
9446
|
-
|
|
9447
|
-
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
|
|
9448
|
-
|
|
9449
|
-
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
|
|
9450
|
-
const env = extendEnv ? {...process$1.env, ...envOption} : envOption;
|
|
9451
|
-
|
|
9452
|
-
if (preferLocal) {
|
|
9453
|
-
return npmRunPathEnv({env, cwd: localDir, execPath});
|
|
9454
|
-
}
|
|
9455
|
-
|
|
9456
|
-
return env;
|
|
9457
|
-
};
|
|
9458
|
-
|
|
9459
|
-
const handleArguments = (file, args, options = {}) => {
|
|
9460
|
-
const parsed = crossSpawn.exports._parse(file, args, options);
|
|
9461
|
-
file = parsed.command;
|
|
9462
|
-
args = parsed.args;
|
|
9463
|
-
options = parsed.options;
|
|
9464
|
-
|
|
9465
|
-
options = {
|
|
9466
|
-
maxBuffer: DEFAULT_MAX_BUFFER,
|
|
9467
|
-
buffer: true,
|
|
9468
|
-
stripFinalNewline: true,
|
|
9469
|
-
extendEnv: true,
|
|
9470
|
-
preferLocal: false,
|
|
9471
|
-
localDir: options.cwd || process$1.cwd(),
|
|
9472
|
-
execPath: process$1.execPath,
|
|
9473
|
-
encoding: 'utf8',
|
|
9474
|
-
reject: true,
|
|
9475
|
-
cleanup: true,
|
|
9476
|
-
all: false,
|
|
9477
|
-
windowsHide: true,
|
|
9478
|
-
...options,
|
|
9479
|
-
};
|
|
9480
|
-
|
|
9481
|
-
options.env = getEnv(options);
|
|
9482
|
-
|
|
9483
|
-
options.stdio = normalizeStdio(options);
|
|
9484
|
-
|
|
9485
|
-
if (process$1.platform === 'win32' && path$a.basename(file, '.exe') === 'cmd') {
|
|
9486
|
-
// #116
|
|
9487
|
-
args.unshift('/q');
|
|
9488
|
-
}
|
|
9489
|
-
|
|
9490
|
-
return {file, args, options, parsed};
|
|
9491
|
-
};
|
|
9492
|
-
|
|
9493
|
-
const handleOutput = (options, value, error) => {
|
|
9494
|
-
if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
|
|
9495
|
-
// When `execaSync()` errors, we normalize it to '' to mimic `execa()`
|
|
9496
|
-
return error === undefined ? undefined : '';
|
|
9497
|
-
}
|
|
9498
|
-
|
|
9499
|
-
if (options.stripFinalNewline) {
|
|
9500
|
-
return stripFinalNewline(value);
|
|
9501
|
-
}
|
|
9502
|
-
|
|
9503
|
-
return value;
|
|
9504
|
-
};
|
|
9505
|
-
|
|
9506
|
-
function execa(file, args, options) {
|
|
9507
|
-
const parsed = handleArguments(file, args, options);
|
|
9508
|
-
const command = joinCommand(file, args);
|
|
9509
|
-
const escapedCommand = getEscapedCommand(file, args);
|
|
9510
|
-
|
|
9511
|
-
validateTimeout(parsed.options);
|
|
9512
|
-
|
|
9513
|
-
let spawned;
|
|
9514
|
-
try {
|
|
9515
|
-
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
|
|
9516
|
-
} catch (error) {
|
|
9517
|
-
// Ensure the returned error is always both a promise and a child process
|
|
9518
|
-
const dummySpawned = new childProcess.ChildProcess();
|
|
9519
|
-
const errorPromise = Promise.reject(makeError({
|
|
9520
|
-
error,
|
|
9521
|
-
stdout: '',
|
|
9522
|
-
stderr: '',
|
|
9523
|
-
all: '',
|
|
9524
|
-
command,
|
|
9525
|
-
escapedCommand,
|
|
9526
|
-
parsed,
|
|
9527
|
-
timedOut: false,
|
|
9528
|
-
isCanceled: false,
|
|
9529
|
-
killed: false,
|
|
9530
|
-
}));
|
|
9531
|
-
return mergePromise(dummySpawned, errorPromise);
|
|
9532
|
-
}
|
|
9533
|
-
|
|
9534
|
-
const spawnedPromise = getSpawnedPromise(spawned);
|
|
9535
|
-
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
|
9536
|
-
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
|
9537
|
-
|
|
9538
|
-
const context = {isCanceled: false};
|
|
9539
|
-
|
|
9540
|
-
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
|
9541
|
-
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
|
9542
|
-
|
|
9543
|
-
const handlePromise = async () => {
|
|
9544
|
-
const [{error, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
|
9545
|
-
const stdout = handleOutput(parsed.options, stdoutResult);
|
|
9546
|
-
const stderr = handleOutput(parsed.options, stderrResult);
|
|
9547
|
-
const all = handleOutput(parsed.options, allResult);
|
|
9548
|
-
|
|
9549
|
-
if (error || exitCode !== 0 || signal !== null) {
|
|
9550
|
-
const returnedError = makeError({
|
|
9551
|
-
error,
|
|
9552
|
-
exitCode,
|
|
9553
|
-
signal,
|
|
9554
|
-
stdout,
|
|
9555
|
-
stderr,
|
|
9556
|
-
all,
|
|
9557
|
-
command,
|
|
9558
|
-
escapedCommand,
|
|
9559
|
-
parsed,
|
|
9560
|
-
timedOut,
|
|
9561
|
-
isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
|
|
9562
|
-
killed: spawned.killed,
|
|
9563
|
-
});
|
|
9564
|
-
|
|
9565
|
-
if (!parsed.options.reject) {
|
|
9566
|
-
return returnedError;
|
|
9567
|
-
}
|
|
9568
|
-
|
|
9569
|
-
throw returnedError;
|
|
9570
|
-
}
|
|
9571
|
-
|
|
9572
|
-
return {
|
|
9573
|
-
command,
|
|
9574
|
-
escapedCommand,
|
|
9575
|
-
exitCode: 0,
|
|
9576
|
-
stdout,
|
|
9577
|
-
stderr,
|
|
9578
|
-
all,
|
|
9579
|
-
failed: false,
|
|
9580
|
-
timedOut: false,
|
|
9581
|
-
isCanceled: false,
|
|
9582
|
-
killed: false,
|
|
9583
|
-
};
|
|
9584
|
-
};
|
|
9585
|
-
|
|
9586
|
-
const handlePromiseOnce = onetime(handlePromise);
|
|
9587
|
-
|
|
9588
|
-
handleInput(spawned, parsed.options.input);
|
|
9589
|
-
|
|
9590
|
-
spawned.all = makeAllStream(spawned, parsed.options);
|
|
9591
|
-
|
|
9592
|
-
return mergePromise(spawned, handlePromiseOnce);
|
|
9593
|
-
}
|
|
9594
|
-
|
|
9595
|
-
class VitestGit {
|
|
9596
|
-
constructor(cwd) {
|
|
9597
|
-
this.cwd = cwd;
|
|
9598
|
-
}
|
|
9599
|
-
async resolveFilesWithGitCommand(args) {
|
|
9600
|
-
let result;
|
|
9601
|
-
try {
|
|
9602
|
-
result = await execa("git", args, { cwd: this.root });
|
|
9603
|
-
} catch (e) {
|
|
9604
|
-
e.message = e.stderr;
|
|
9605
|
-
throw e;
|
|
9606
|
-
}
|
|
9607
|
-
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
|
9608
|
-
}
|
|
9609
|
-
async findChangedFiles(options) {
|
|
9610
|
-
const root = await this.getRoot(this.cwd);
|
|
9611
|
-
if (!root)
|
|
9612
|
-
return null;
|
|
9613
|
-
this.root = root;
|
|
9614
|
-
const changedSince = options.changedSince;
|
|
9615
|
-
if (typeof changedSince === "string") {
|
|
9616
|
-
const [committed, staged2, unstaged2] = await Promise.all([
|
|
9617
|
-
this.getFilesSince(changedSince),
|
|
9618
|
-
this.getStagedFiles(),
|
|
9619
|
-
this.getUnstagedFiles()
|
|
9620
|
-
]);
|
|
9621
|
-
return [...committed, ...staged2, ...unstaged2];
|
|
9622
|
-
}
|
|
9623
|
-
const [staged, unstaged] = await Promise.all([
|
|
9624
|
-
this.getStagedFiles(),
|
|
9625
|
-
this.getUnstagedFiles()
|
|
9626
|
-
]);
|
|
9627
|
-
return [...staged, ...unstaged];
|
|
9628
|
-
}
|
|
9629
|
-
getFilesSince(hash) {
|
|
9630
|
-
return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
|
|
9631
|
-
}
|
|
9632
|
-
getStagedFiles() {
|
|
9633
|
-
return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
|
|
9634
|
-
}
|
|
9635
|
-
getUnstagedFiles() {
|
|
9636
|
-
return this.resolveFilesWithGitCommand([
|
|
9637
|
-
"ls-files",
|
|
9638
|
-
"--other",
|
|
9639
|
-
"--modified",
|
|
9640
|
-
"--exclude-standard"
|
|
9641
|
-
]);
|
|
9642
|
-
}
|
|
9643
|
-
async getRoot(cwd) {
|
|
9644
|
-
const options = ["rev-parse", "--show-cdup"];
|
|
9645
|
-
try {
|
|
9646
|
-
const result = await execa("git", options, { cwd });
|
|
9647
|
-
return resolve(cwd, result.stdout);
|
|
9648
|
-
} catch {
|
|
9649
|
-
return null;
|
|
9650
|
-
}
|
|
9651
|
-
}
|
|
9652
|
-
}
|
|
9653
|
-
|
|
9654
8609
|
const ESC = '\u001B[';
|
|
9655
8610
|
const OSC = '\u001B]';
|
|
9656
8611
|
const BEL = '\u0007';
|
|
@@ -9806,7 +8761,7 @@ ansiEscapes.iTerm = {
|
|
|
9806
8761
|
}
|
|
9807
8762
|
};
|
|
9808
8763
|
|
|
9809
|
-
const restoreCursor = onetime
|
|
8764
|
+
const restoreCursor = onetime.exports(() => {
|
|
9810
8765
|
signalExit.exports(() => {
|
|
9811
8766
|
process$1.stderr.write('\u001B[?25h');
|
|
9812
8767
|
}, {alwaysLast: true});
|
|
@@ -10137,7 +9092,7 @@ createLogUpdate(process$1.stdout);
|
|
|
10137
9092
|
|
|
10138
9093
|
createLogUpdate(process$1.stderr);
|
|
10139
9094
|
|
|
10140
|
-
var version = "0.
|
|
9095
|
+
var version = "0.20.0";
|
|
10141
9096
|
|
|
10142
9097
|
function fileFromParsedStack(stack) {
|
|
10143
9098
|
var _a, _b;
|
|
@@ -10288,7 +9243,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
10288
9243
|
const lineLength = lines[j].length;
|
|
10289
9244
|
if (lineLength > 200)
|
|
10290
9245
|
return "";
|
|
10291
|
-
res.push(lineNo(j + 1) + cliTruncate(lines[j], columns - 5 - indent));
|
|
9246
|
+
res.push(lineNo(j + 1) + cliTruncate(lines[j].replace(/\t/g, " "), columns - 5 - indent));
|
|
10292
9247
|
if (j === i) {
|
|
10293
9248
|
const pad = start - (count - lineLength);
|
|
10294
9249
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
@@ -10369,15 +9324,17 @@ class Logger {
|
|
|
10369
9324
|
this.error(picocolors.exports.red("\nNo test files found, exiting with code 1"));
|
|
10370
9325
|
}
|
|
10371
9326
|
printBanner() {
|
|
10372
|
-
var _a, _b;
|
|
9327
|
+
var _a, _b, _c;
|
|
10373
9328
|
this.log();
|
|
10374
9329
|
const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
|
|
10375
9330
|
const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
|
|
10376
9331
|
this.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
|
|
10377
|
-
if (this.ctx.config.
|
|
10378
|
-
this.log(picocolors.exports.dim(picocolors.exports.green(`
|
|
9332
|
+
if (this.ctx.config.browser)
|
|
9333
|
+
this.log(picocolors.exports.dim(picocolors.exports.green(` Browser runner started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
|
|
9334
|
+
else if (this.ctx.config.ui)
|
|
9335
|
+
this.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
|
|
10379
9336
|
else if (this.ctx.config.api)
|
|
10380
|
-
this.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((
|
|
9337
|
+
this.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
|
|
10381
9338
|
this.log();
|
|
10382
9339
|
}
|
|
10383
9340
|
async printUnhandledErrors(errors) {
|
|
@@ -10394,7 +9351,6 @@ Please, resolve all the errors to make sure your tests are not affected.`));
|
|
|
10394
9351
|
}
|
|
10395
9352
|
|
|
10396
9353
|
const WATCHER_DEBOUNCE = 100;
|
|
10397
|
-
const CLOSE_TIMEOUT = 1e3;
|
|
10398
9354
|
class Vitest {
|
|
10399
9355
|
constructor() {
|
|
10400
9356
|
this.config = void 0;
|
|
@@ -10479,7 +9435,7 @@ class Vitest {
|
|
|
10479
9435
|
await this.runFiles(files);
|
|
10480
9436
|
if (this.config.coverage.enabled)
|
|
10481
9437
|
await reportCoverage(this);
|
|
10482
|
-
if (this.config.watch)
|
|
9438
|
+
if (this.config.watch && !this.config.browser)
|
|
10483
9439
|
await this.report("onWatcherStart");
|
|
10484
9440
|
}
|
|
10485
9441
|
async getTestDependencies(filepath) {
|
|
@@ -10503,6 +9459,7 @@ class Vitest {
|
|
|
10503
9459
|
}
|
|
10504
9460
|
async filterTestsBySource(tests) {
|
|
10505
9461
|
if (this.config.changed && !this.config.related) {
|
|
9462
|
+
const { VitestGit } = await import('./chunk-node-git.43dbdd42.mjs');
|
|
10506
9463
|
const vitestGit = new VitestGit(this.config.root);
|
|
10507
9464
|
const related2 = await vitestGit.findChangedFiles({
|
|
10508
9465
|
changedSince: this.config.changed
|
|
@@ -10534,6 +9491,7 @@ class Vitest {
|
|
|
10534
9491
|
}
|
|
10535
9492
|
async runFiles(paths) {
|
|
10536
9493
|
await this.runningPromise;
|
|
9494
|
+
this.state.startCollectingPaths();
|
|
10537
9495
|
this.runningPromise = (async () => {
|
|
10538
9496
|
if (!this.pool)
|
|
10539
9497
|
this.pool = createPool(this);
|
|
@@ -10549,18 +9507,21 @@ class Vitest {
|
|
|
10549
9507
|
const files = this.state.getFiles();
|
|
10550
9508
|
if (hasFailed(files))
|
|
10551
9509
|
process.exitCode = 1;
|
|
10552
|
-
|
|
9510
|
+
if (!this.config.browser)
|
|
9511
|
+
await this.report("onFinished", files, this.state.getUnhandledErrors());
|
|
10553
9512
|
this.cache.results.updateResults(files);
|
|
10554
9513
|
await this.cache.results.writeToCache();
|
|
10555
9514
|
})().finally(() => {
|
|
10556
9515
|
this.runningPromise = void 0;
|
|
9516
|
+
this.state.finishCollectingPaths();
|
|
10557
9517
|
});
|
|
10558
9518
|
return await this.runningPromise;
|
|
10559
9519
|
}
|
|
10560
9520
|
async rerunFiles(files = this.state.getFilepaths(), trigger) {
|
|
10561
9521
|
await this.report("onWatcherRerun", files, trigger);
|
|
10562
9522
|
await this.runFiles(files);
|
|
10563
|
-
|
|
9523
|
+
if (!this.config.browser)
|
|
9524
|
+
await this.report("onWatcherStart");
|
|
10564
9525
|
}
|
|
10565
9526
|
async changeNamePattern(pattern, files = this.state.getFilepaths(), trigger) {
|
|
10566
9527
|
this.config.testNamePattern = pattern ? new RegExp(pattern) : void 0;
|
|
@@ -10609,7 +9570,8 @@ class Vitest {
|
|
|
10609
9570
|
await this.runFiles(files);
|
|
10610
9571
|
if (this.config.coverage.enabled)
|
|
10611
9572
|
await reportCoverage(this);
|
|
10612
|
-
|
|
9573
|
+
if (!this.config.browser)
|
|
9574
|
+
await this.report("onWatcherStart");
|
|
10613
9575
|
}, WATCHER_DEBOUNCE);
|
|
10614
9576
|
}
|
|
10615
9577
|
registerWatcher() {
|
|
@@ -10693,9 +9655,9 @@ class Vitest {
|
|
|
10693
9655
|
}
|
|
10694
9656
|
async exit(force = false) {
|
|
10695
9657
|
safeSetTimeout(() => {
|
|
10696
|
-
console.warn(`close timed out after ${
|
|
9658
|
+
console.warn(`close timed out after ${this.config.teardownTimeout}ms`);
|
|
10697
9659
|
process.exit();
|
|
10698
|
-
},
|
|
9660
|
+
}, this.config.teardownTimeout).unref();
|
|
10699
9661
|
await this.close();
|
|
10700
9662
|
if (force)
|
|
10701
9663
|
process.exit();
|
|
@@ -10986,9 +9948,15 @@ function CSSEnablerPlugin(ctx) {
|
|
|
10986
9948
|
async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
10987
9949
|
let haveStarted = false;
|
|
10988
9950
|
async function UIPlugin() {
|
|
10989
|
-
|
|
9951
|
+
var _a;
|
|
9952
|
+
await ensurePackageInstalled("@vitest/ui", ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd());
|
|
10990
9953
|
return (await import('@vitest/ui')).default(options.uiBase);
|
|
10991
9954
|
}
|
|
9955
|
+
async function BrowserPlugin() {
|
|
9956
|
+
var _a;
|
|
9957
|
+
await ensurePackageInstalled("@vitest/browser", ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd());
|
|
9958
|
+
return (await import('@vitest/browser')).default("/");
|
|
9959
|
+
}
|
|
10992
9960
|
return [
|
|
10993
9961
|
{
|
|
10994
9962
|
name: "vitest",
|
|
@@ -11023,10 +9991,15 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11023
9991
|
}
|
|
11024
9992
|
}
|
|
11025
9993
|
options.defines = defines;
|
|
11026
|
-
|
|
9994
|
+
let open;
|
|
9995
|
+
if (preOptions.ui && preOptions.open)
|
|
9996
|
+
open = preOptions.uiBase ?? "/__vitest__/";
|
|
9997
|
+
else if (preOptions.browser)
|
|
9998
|
+
open = "/";
|
|
11027
9999
|
const config = {
|
|
11028
10000
|
resolve: {
|
|
11029
|
-
mainFields: []
|
|
10001
|
+
mainFields: [],
|
|
10002
|
+
alias: preOptions.alias
|
|
11030
10003
|
},
|
|
11031
10004
|
server: {
|
|
11032
10005
|
...preOptions.api,
|
|
@@ -11036,13 +10009,17 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11036
10009
|
open,
|
|
11037
10010
|
hmr: false,
|
|
11038
10011
|
preTransformRequests: false
|
|
11039
|
-
},
|
|
11040
|
-
cacheDir: void 0,
|
|
11041
|
-
optimizeDeps: {
|
|
11042
|
-
disabled: true,
|
|
11043
|
-
entries: []
|
|
11044
10012
|
}
|
|
11045
10013
|
};
|
|
10014
|
+
if (!options.browser) {
|
|
10015
|
+
Object.assign(config, {
|
|
10016
|
+
cacheDir: void 0,
|
|
10017
|
+
optimizeDeps: {
|
|
10018
|
+
disabled: true,
|
|
10019
|
+
entries: []
|
|
10020
|
+
}
|
|
10021
|
+
});
|
|
10022
|
+
}
|
|
11046
10023
|
return config;
|
|
11047
10024
|
},
|
|
11048
10025
|
async configResolved(viteConfig) {
|
|
@@ -11050,6 +10027,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11050
10027
|
const viteConfigTest = viteConfig.test || {};
|
|
11051
10028
|
if (viteConfigTest.watch === false)
|
|
11052
10029
|
viteConfigTest.run = true;
|
|
10030
|
+
if ("alias" in viteConfigTest)
|
|
10031
|
+
delete viteConfigTest.alias;
|
|
11053
10032
|
options = deepMerge({}, configDefaults, viteConfigTest, options);
|
|
11054
10033
|
options.api = resolveApiConfig(options);
|
|
11055
10034
|
const { PROD, DEV, ...envs } = viteConfig.env;
|
|
@@ -11066,7 +10045,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11066
10045
|
await ctx.setServer(options, server);
|
|
11067
10046
|
haveStarted = true;
|
|
11068
10047
|
if (options.api && options.watch)
|
|
11069
|
-
(await import('./chunk-api-setup.
|
|
10048
|
+
(await import('./chunk-api-setup.7c4c8879.mjs')).setup(ctx);
|
|
11070
10049
|
} catch (err) {
|
|
11071
10050
|
ctx.logger.printError(err, true);
|
|
11072
10051
|
process.exit(1);
|
|
@@ -11078,6 +10057,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11078
10057
|
EnvReplacerPlugin(),
|
|
11079
10058
|
MocksPlugin(),
|
|
11080
10059
|
GlobalSetupPlugin(ctx),
|
|
10060
|
+
...options.browser ? await BrowserPlugin() : [],
|
|
11081
10061
|
CSSEnablerPlugin(ctx),
|
|
11082
10062
|
options.ui ? await UIPlugin() : null
|
|
11083
10063
|
].filter(notNullish);
|
|
@@ -11152,8 +10132,8 @@ function registerConsoleShortcuts(ctx) {
|
|
|
11152
10132
|
let rl;
|
|
11153
10133
|
function on() {
|
|
11154
10134
|
off();
|
|
11155
|
-
rl = require$$0$
|
|
11156
|
-
require$$0$
|
|
10135
|
+
rl = require$$0$2.createInterface({ input: process.stdin, escapeCodeTimeout: 50 });
|
|
10136
|
+
require$$0$2.emitKeypressEvents(process.stdin, rl);
|
|
11157
10137
|
if (process.stdin.isTTY)
|
|
11158
10138
|
process.stdin.setRawMode(true);
|
|
11159
10139
|
process.stdin.on("keypress", keypressHandler);
|
|
@@ -11175,7 +10155,10 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11175
10155
|
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
|
|
11176
10156
|
if (options.run)
|
|
11177
10157
|
options.watch = false;
|
|
11178
|
-
if (
|
|
10158
|
+
if (options.browser)
|
|
10159
|
+
options.threads = false;
|
|
10160
|
+
const root = resolve(options.root || process.cwd());
|
|
10161
|
+
if (!await ensurePackageInstalled("vite", root)) {
|
|
11179
10162
|
process.exitCode = 1;
|
|
11180
10163
|
return false;
|
|
11181
10164
|
}
|
|
@@ -11183,14 +10166,14 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11183
10166
|
options.coverage = { enabled: options.coverage };
|
|
11184
10167
|
const ctx = await createVitest(options, viteOverrides);
|
|
11185
10168
|
if (ctx.config.coverage.enabled) {
|
|
11186
|
-
if (!await ensurePackageInstalled("c8")) {
|
|
10169
|
+
if (!await ensurePackageInstalled("c8", root)) {
|
|
11187
10170
|
process.exitCode = 1;
|
|
11188
10171
|
return false;
|
|
11189
10172
|
}
|
|
11190
10173
|
}
|
|
11191
10174
|
if (ctx.config.environment && ctx.config.environment !== "node") {
|
|
11192
10175
|
const packageName = envPackageNames[ctx.config.environment];
|
|
11193
|
-
if (!await ensurePackageInstalled(packageName)) {
|
|
10176
|
+
if (!await ensurePackageInstalled(packageName, root)) {
|
|
11194
10177
|
process.exitCode = 1;
|
|
11195
10178
|
return false;
|
|
11196
10179
|
}
|