vitest 0.18.1 → 0.19.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 +1850 -0
- package/dist/browser.mjs +20 -0
- package/dist/{chunk-api-setup.9d3f7670.mjs → chunk-api-setup.0cf2c96a.mjs} +23 -6
- package/dist/{chunk-constants.d4406290.mjs → chunk-constants.38b43a44.mjs} +3 -3
- package/dist/{chunk-env-node.bbba78e5.mjs → chunk-defaults.408a0cfe.mjs} +456 -455
- package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
- package/dist/{chunk-integrations-globals.00b6e1ad.mjs → chunk-integrations-globals.803277be.mjs} +6 -5
- package/dist/chunk-node-git.9058b82a.mjs +1139 -0
- package/dist/chunk-runtime-chain.1e1aabb3.mjs +2025 -0
- package/dist/chunk-runtime-error.d82dd2cf.mjs +644 -0
- package/dist/{chunk-runtime-chain.b60d57da.mjs → chunk-runtime-hooks.db398170.mjs} +10 -2013
- package/dist/{chunk-runtime-mocker.1d853e3a.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +3 -3
- package/dist/{chunk-runtime-rpc.9d1f4c48.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
- package/dist/{chunk-utils-global.0a7416cf.mjs → chunk-utils-global.2aa95025.mjs} +11 -6
- package/dist/{chunk-utils-source-map.c03f8bc4.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
- package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.a2813ad7.mjs} +103 -1173
- package/dist/{chunk-vite-node-utils.8077cd3c.mjs → chunk-vite-node-utils.ad73f2ab.mjs} +13 -2
- package/dist/cli.mjs +8 -10
- package/dist/config.cjs +3 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +3 -1
- package/dist/entry.mjs +14 -597
- package/dist/index.d.ts +39 -4
- package/dist/index.mjs +8 -5
- package/dist/node.d.ts +28 -2
- package/dist/node.mjs +10 -12
- package/dist/suite.mjs +13 -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 +5 -5
- package/package.json +11 -3
package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.a2813ad7.mjs}
RENAMED
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import {
|
|
1
|
+
import { j as join, D as basename, d as dirname, C as resolve, E as AggregateErrorPonyfill, p as picocolors, F as isAbsolute, G as relative, c as slash$2, t as isNode, v as relativePath, H as getTests, h as getFullName, B as hasFailed, I as hasFailedSnapshot, J as safeSetInterval, K as safeClearInterval, L as getSuites, s as safeSetTimeout, z as shuffle, u as toArray$1, M as normalize, n as noop$1, k as safeClearTimeout, N as deepMerge, O as toNamespacedPath, b as getCallLastIndex, l as notNullish, P as ensurePackageInstalled, Q as stdout } from './chunk-utils-global.2aa95025.mjs';
|
|
2
|
+
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, d as envPackageNames } from './chunk-defaults.408a0cfe.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, c as configFiles, a as defaultPort } from './chunk-constants.38b43a44.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 { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
14
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.ad73f2ab.mjs';
|
|
15
15
|
import createDebug from 'debug';
|
|
16
16
|
import { MessageChannel } from 'worker_threads';
|
|
17
17
|
import { Tinypool } from 'tinypool';
|
|
18
18
|
import { performance } from 'perf_hooks';
|
|
19
|
-
import { c as stripAnsi, d as cliTruncate,
|
|
19
|
+
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.8b066ce2.mjs';
|
|
20
20
|
import { resolveModule } from 'local-pkg';
|
|
21
21
|
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';
|
|
22
|
+
import { o as onetime, s as signalExit } from './vendor-index.61438b77.mjs';
|
|
25
23
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
26
|
-
import require$$0$
|
|
24
|
+
import require$$0$2 from 'readline';
|
|
27
25
|
import { p as prompts } from './vendor-index.de788b6a.mjs';
|
|
28
26
|
|
|
29
|
-
var version$1 = "0.
|
|
27
|
+
var version$1 = "0.19.0";
|
|
30
28
|
|
|
31
29
|
class EndError extends Error {
|
|
32
30
|
constructor(value) {
|
|
@@ -935,7 +933,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
935
933
|
* Licensed under the MIT License.
|
|
936
934
|
*/
|
|
937
935
|
|
|
938
|
-
const util$1 =
|
|
936
|
+
const util$1 = util$2;
|
|
939
937
|
const toRegexRange = toRegexRange_1;
|
|
940
938
|
|
|
941
939
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -3972,7 +3970,7 @@ var picomatch_1 = picomatch$1;
|
|
|
3972
3970
|
module.exports = picomatch_1;
|
|
3973
3971
|
} (picomatch$2));
|
|
3974
3972
|
|
|
3975
|
-
const util =
|
|
3973
|
+
const util = util$2;
|
|
3976
3974
|
const braces = braces_1;
|
|
3977
3975
|
const picomatch = picomatch$2.exports;
|
|
3978
3976
|
const utils$b = utils$f;
|
|
@@ -4616,7 +4614,7 @@ var stream$4 = {};
|
|
|
4616
4614
|
* Copyright (c) 2014-2020 Teambition
|
|
4617
4615
|
* Licensed under the MIT license.
|
|
4618
4616
|
*/
|
|
4619
|
-
const Stream = require$$0$
|
|
4617
|
+
const Stream = require$$0$1;
|
|
4620
4618
|
const PassThrough = Stream.PassThrough;
|
|
4621
4619
|
const slice = Array.prototype.slice;
|
|
4622
4620
|
|
|
@@ -5900,7 +5898,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
5900
5898
|
var stream$1 = {};
|
|
5901
5899
|
|
|
5902
5900
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
5903
|
-
const stream_1$5 = require$$0$
|
|
5901
|
+
const stream_1$5 = require$$0$1;
|
|
5904
5902
|
const async_1$2 = async$2;
|
|
5905
5903
|
class StreamProvider {
|
|
5906
5904
|
constructor(_root, _settings) {
|
|
@@ -6108,7 +6106,7 @@ class Reader {
|
|
|
6108
6106
|
reader.default = Reader;
|
|
6109
6107
|
|
|
6110
6108
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
6111
|
-
const stream_1$3 = require$$0$
|
|
6109
|
+
const stream_1$3 = require$$0$1;
|
|
6112
6110
|
const fsStat$1 = out$3;
|
|
6113
6111
|
const fsWalk$1 = out$2;
|
|
6114
6112
|
const reader_1$1 = reader;
|
|
@@ -6506,7 +6504,7 @@ async$6.default = ProviderAsync;
|
|
|
6506
6504
|
var stream = {};
|
|
6507
6505
|
|
|
6508
6506
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6509
|
-
const stream_1$1 = require$$0$
|
|
6507
|
+
const stream_1$1 = require$$0$1;
|
|
6510
6508
|
const stream_2 = stream$2;
|
|
6511
6509
|
const provider_1$1 = provider;
|
|
6512
6510
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -6739,7 +6737,7 @@ const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
|
6739
6737
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
6740
6738
|
const defaultInline = [
|
|
6741
6739
|
/virtual:/,
|
|
6742
|
-
/\.ts$/
|
|
6740
|
+
/\.[mc]?ts$/
|
|
6743
6741
|
];
|
|
6744
6742
|
const depsExternal = [
|
|
6745
6743
|
/\.cjs\.js$/,
|
|
@@ -6980,7 +6978,7 @@ function addSnapshotResult(summary, result) {
|
|
|
6980
6978
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
6981
6979
|
}
|
|
6982
6980
|
|
|
6983
|
-
const workerPath = pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
6981
|
+
const workerPath = _url.pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
6984
6982
|
function createPool(ctx) {
|
|
6985
6983
|
var _a;
|
|
6986
6984
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
|
|
@@ -7084,6 +7082,10 @@ function createChannel(ctx) {
|
|
|
7084
7082
|
resolveId(id, importer) {
|
|
7085
7083
|
return ctx.vitenode.resolveId(id, importer);
|
|
7086
7084
|
},
|
|
7085
|
+
onPathsCollected(paths) {
|
|
7086
|
+
ctx.state.collectPaths(paths);
|
|
7087
|
+
ctx.report("onPathsCollected", paths);
|
|
7088
|
+
},
|
|
7087
7089
|
onCollected(files) {
|
|
7088
7090
|
ctx.state.collectFiles(files);
|
|
7089
7091
|
ctx.report("onCollected", files);
|
|
@@ -7287,7 +7289,7 @@ class BaseReporter {
|
|
|
7287
7289
|
this.start = performance.now();
|
|
7288
7290
|
}
|
|
7289
7291
|
relative(path) {
|
|
7290
|
-
return
|
|
7292
|
+
return relativePath(this.ctx.config.root, path);
|
|
7291
7293
|
}
|
|
7292
7294
|
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
7293
7295
|
this.end = performance.now();
|
|
@@ -7817,7 +7819,8 @@ class JsonReporter {
|
|
|
7817
7819
|
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
7818
7820
|
title: t.name,
|
|
7819
7821
|
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]
|
|
7822
|
+
failureMessages: ((_d = (_c = t.result) == null ? void 0 : _c.error) == null ? void 0 : _d.message) == null ? [] : [t.result.error.message],
|
|
7823
|
+
location: this.getFailureLocation(t)
|
|
7821
7824
|
};
|
|
7822
7825
|
});
|
|
7823
7826
|
if (tests2.some((t) => {
|
|
@@ -7870,6 +7873,18 @@ class JsonReporter {
|
|
|
7870
7873
|
this.ctx.logger.log(report);
|
|
7871
7874
|
}
|
|
7872
7875
|
}
|
|
7876
|
+
getFailureLocation(test) {
|
|
7877
|
+
var _a;
|
|
7878
|
+
const error = (_a = test.result) == null ? void 0 : _a.error;
|
|
7879
|
+
if (!error)
|
|
7880
|
+
return;
|
|
7881
|
+
const stack = parseStacktrace(error);
|
|
7882
|
+
const frame = stack[stack.length - 1];
|
|
7883
|
+
if (!frame)
|
|
7884
|
+
return;
|
|
7885
|
+
const pos = frame.sourcePos || frame;
|
|
7886
|
+
return { line: pos.line, column: pos.column };
|
|
7887
|
+
}
|
|
7873
7888
|
}
|
|
7874
7889
|
|
|
7875
7890
|
class VerboseReporter extends DefaultReporter {
|
|
@@ -8196,6 +8211,7 @@ function createReporters(reporterReferences, runner) {
|
|
|
8196
8211
|
class StateManager {
|
|
8197
8212
|
constructor() {
|
|
8198
8213
|
this.filesMap = /* @__PURE__ */ new Map();
|
|
8214
|
+
this.pathsSet = /* @__PURE__ */ new Set();
|
|
8199
8215
|
this.idMap = /* @__PURE__ */ new Map();
|
|
8200
8216
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
8201
8217
|
this.errorsSet = /* @__PURE__ */ new Set();
|
|
@@ -8210,6 +8226,9 @@ class StateManager {
|
|
|
8210
8226
|
getUnhandledErrors() {
|
|
8211
8227
|
return Array.from(this.errorsSet.values());
|
|
8212
8228
|
}
|
|
8229
|
+
getPaths() {
|
|
8230
|
+
return Array.from(this.pathsSet);
|
|
8231
|
+
}
|
|
8213
8232
|
getFiles(keys) {
|
|
8214
8233
|
if (keys)
|
|
8215
8234
|
return keys.map((key) => this.filesMap.get(key)).filter(Boolean);
|
|
@@ -8224,6 +8243,11 @@ class StateManager {
|
|
|
8224
8243
|
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
8225
8244
|
}).map((i) => i.filepath);
|
|
8226
8245
|
}
|
|
8246
|
+
collectPaths(paths = []) {
|
|
8247
|
+
paths.forEach((path) => {
|
|
8248
|
+
this.pathsSet.add(path);
|
|
8249
|
+
});
|
|
8250
|
+
}
|
|
8227
8251
|
collectFiles(files = []) {
|
|
8228
8252
|
files.forEach((file) => {
|
|
8229
8253
|
this.filesMap.set(file.filepath, file);
|
|
@@ -8430,7 +8454,7 @@ const extraInlineDeps = [
|
|
|
8430
8454
|
];
|
|
8431
8455
|
function resolveApiConfig(options) {
|
|
8432
8456
|
let api;
|
|
8433
|
-
if (options.ui && !options.api)
|
|
8457
|
+
if ((options.ui || options.browser) && !options.api)
|
|
8434
8458
|
api = { port: defaultPort };
|
|
8435
8459
|
else if (options.api === true)
|
|
8436
8460
|
api = { port: defaultPort };
|
|
@@ -8531,1126 +8555,6 @@ function resolveConfig(options, viteConfig) {
|
|
|
8531
8555
|
return resolved;
|
|
8532
8556
|
}
|
|
8533
8557
|
|
|
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
8558
|
const ESC = '\u001B[';
|
|
9655
8559
|
const OSC = '\u001B]';
|
|
9656
8560
|
const BEL = '\u0007';
|
|
@@ -9806,7 +8710,7 @@ ansiEscapes.iTerm = {
|
|
|
9806
8710
|
}
|
|
9807
8711
|
};
|
|
9808
8712
|
|
|
9809
|
-
const restoreCursor = onetime
|
|
8713
|
+
const restoreCursor = onetime.exports(() => {
|
|
9810
8714
|
signalExit.exports(() => {
|
|
9811
8715
|
process$1.stderr.write('\u001B[?25h');
|
|
9812
8716
|
}, {alwaysLast: true});
|
|
@@ -10137,7 +9041,7 @@ createLogUpdate(process$1.stdout);
|
|
|
10137
9041
|
|
|
10138
9042
|
createLogUpdate(process$1.stderr);
|
|
10139
9043
|
|
|
10140
|
-
var version = "0.
|
|
9044
|
+
var version = "0.19.0";
|
|
10141
9045
|
|
|
10142
9046
|
function fileFromParsedStack(stack) {
|
|
10143
9047
|
var _a, _b;
|
|
@@ -10288,7 +9192,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
10288
9192
|
const lineLength = lines[j].length;
|
|
10289
9193
|
if (lineLength > 200)
|
|
10290
9194
|
return "";
|
|
10291
|
-
res.push(lineNo(j + 1) + cliTruncate(lines[j], columns - 5 - indent));
|
|
9195
|
+
res.push(lineNo(j + 1) + cliTruncate(lines[j].replace(/\t/g, " "), columns - 5 - indent));
|
|
10292
9196
|
if (j === i) {
|
|
10293
9197
|
const pad = start - (count - lineLength);
|
|
10294
9198
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
@@ -10369,15 +9273,17 @@ class Logger {
|
|
|
10369
9273
|
this.error(picocolors.exports.red("\nNo test files found, exiting with code 1"));
|
|
10370
9274
|
}
|
|
10371
9275
|
printBanner() {
|
|
10372
|
-
var _a, _b;
|
|
9276
|
+
var _a, _b, _c;
|
|
10373
9277
|
this.log();
|
|
10374
9278
|
const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
|
|
10375
9279
|
const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
|
|
10376
9280
|
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(`
|
|
9281
|
+
if (this.ctx.config.browser)
|
|
9282
|
+
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}`)}`)));
|
|
9283
|
+
else if (this.ctx.config.ui)
|
|
9284
|
+
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
9285
|
else if (this.ctx.config.api)
|
|
10380
|
-
this.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((
|
|
9286
|
+
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
9287
|
this.log();
|
|
10382
9288
|
}
|
|
10383
9289
|
async printUnhandledErrors(errors) {
|
|
@@ -10394,7 +9300,6 @@ Please, resolve all the errors to make sure your tests are not affected.`));
|
|
|
10394
9300
|
}
|
|
10395
9301
|
|
|
10396
9302
|
const WATCHER_DEBOUNCE = 100;
|
|
10397
|
-
const CLOSE_TIMEOUT = 1e3;
|
|
10398
9303
|
class Vitest {
|
|
10399
9304
|
constructor() {
|
|
10400
9305
|
this.config = void 0;
|
|
@@ -10479,7 +9384,7 @@ class Vitest {
|
|
|
10479
9384
|
await this.runFiles(files);
|
|
10480
9385
|
if (this.config.coverage.enabled)
|
|
10481
9386
|
await reportCoverage(this);
|
|
10482
|
-
if (this.config.watch)
|
|
9387
|
+
if (this.config.watch && !this.config.browser)
|
|
10483
9388
|
await this.report("onWatcherStart");
|
|
10484
9389
|
}
|
|
10485
9390
|
async getTestDependencies(filepath) {
|
|
@@ -10503,6 +9408,7 @@ class Vitest {
|
|
|
10503
9408
|
}
|
|
10504
9409
|
async filterTestsBySource(tests) {
|
|
10505
9410
|
if (this.config.changed && !this.config.related) {
|
|
9411
|
+
const { VitestGit } = await import('./chunk-node-git.9058b82a.mjs');
|
|
10506
9412
|
const vitestGit = new VitestGit(this.config.root);
|
|
10507
9413
|
const related2 = await vitestGit.findChangedFiles({
|
|
10508
9414
|
changedSince: this.config.changed
|
|
@@ -10549,7 +9455,8 @@ class Vitest {
|
|
|
10549
9455
|
const files = this.state.getFiles();
|
|
10550
9456
|
if (hasFailed(files))
|
|
10551
9457
|
process.exitCode = 1;
|
|
10552
|
-
|
|
9458
|
+
if (!this.config.browser)
|
|
9459
|
+
await this.report("onFinished", files, this.state.getUnhandledErrors());
|
|
10553
9460
|
this.cache.results.updateResults(files);
|
|
10554
9461
|
await this.cache.results.writeToCache();
|
|
10555
9462
|
})().finally(() => {
|
|
@@ -10560,7 +9467,8 @@ class Vitest {
|
|
|
10560
9467
|
async rerunFiles(files = this.state.getFilepaths(), trigger) {
|
|
10561
9468
|
await this.report("onWatcherRerun", files, trigger);
|
|
10562
9469
|
await this.runFiles(files);
|
|
10563
|
-
|
|
9470
|
+
if (!this.config.browser)
|
|
9471
|
+
await this.report("onWatcherStart");
|
|
10564
9472
|
}
|
|
10565
9473
|
async changeNamePattern(pattern, files = this.state.getFilepaths(), trigger) {
|
|
10566
9474
|
this.config.testNamePattern = pattern ? new RegExp(pattern) : void 0;
|
|
@@ -10609,7 +9517,8 @@ class Vitest {
|
|
|
10609
9517
|
await this.runFiles(files);
|
|
10610
9518
|
if (this.config.coverage.enabled)
|
|
10611
9519
|
await reportCoverage(this);
|
|
10612
|
-
|
|
9520
|
+
if (!this.config.browser)
|
|
9521
|
+
await this.report("onWatcherStart");
|
|
10613
9522
|
}, WATCHER_DEBOUNCE);
|
|
10614
9523
|
}
|
|
10615
9524
|
registerWatcher() {
|
|
@@ -10693,9 +9602,9 @@ class Vitest {
|
|
|
10693
9602
|
}
|
|
10694
9603
|
async exit(force = false) {
|
|
10695
9604
|
safeSetTimeout(() => {
|
|
10696
|
-
console.warn(`close timed out after ${
|
|
9605
|
+
console.warn(`close timed out after ${this.config.teardownTimeout}ms`);
|
|
10697
9606
|
process.exit();
|
|
10698
|
-
},
|
|
9607
|
+
}, this.config.teardownTimeout).unref();
|
|
10699
9608
|
await this.close();
|
|
10700
9609
|
if (force)
|
|
10701
9610
|
process.exit();
|
|
@@ -10986,9 +9895,15 @@ function CSSEnablerPlugin(ctx) {
|
|
|
10986
9895
|
async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
10987
9896
|
let haveStarted = false;
|
|
10988
9897
|
async function UIPlugin() {
|
|
10989
|
-
|
|
9898
|
+
var _a;
|
|
9899
|
+
await ensurePackageInstalled("@vitest/ui", ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd());
|
|
10990
9900
|
return (await import('@vitest/ui')).default(options.uiBase);
|
|
10991
9901
|
}
|
|
9902
|
+
async function BrowserPlugin() {
|
|
9903
|
+
var _a;
|
|
9904
|
+
await ensurePackageInstalled("@vitest/browser", ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd());
|
|
9905
|
+
return (await import('@vitest/browser')).default("/");
|
|
9906
|
+
}
|
|
10992
9907
|
return [
|
|
10993
9908
|
{
|
|
10994
9909
|
name: "vitest",
|
|
@@ -11023,10 +9938,15 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11023
9938
|
}
|
|
11024
9939
|
}
|
|
11025
9940
|
options.defines = defines;
|
|
11026
|
-
|
|
9941
|
+
let open;
|
|
9942
|
+
if (preOptions.ui && preOptions.open)
|
|
9943
|
+
open = preOptions.uiBase ?? "/__vitest__/";
|
|
9944
|
+
else if (preOptions.browser)
|
|
9945
|
+
open = "/";
|
|
11027
9946
|
const config = {
|
|
11028
9947
|
resolve: {
|
|
11029
|
-
mainFields: []
|
|
9948
|
+
mainFields: [],
|
|
9949
|
+
alias: preOptions.alias
|
|
11030
9950
|
},
|
|
11031
9951
|
server: {
|
|
11032
9952
|
...preOptions.api,
|
|
@@ -11036,13 +9956,17 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11036
9956
|
open,
|
|
11037
9957
|
hmr: false,
|
|
11038
9958
|
preTransformRequests: false
|
|
11039
|
-
},
|
|
11040
|
-
cacheDir: void 0,
|
|
11041
|
-
optimizeDeps: {
|
|
11042
|
-
disabled: true,
|
|
11043
|
-
entries: []
|
|
11044
9959
|
}
|
|
11045
9960
|
};
|
|
9961
|
+
if (!options.browser) {
|
|
9962
|
+
Object.assign(config, {
|
|
9963
|
+
cacheDir: void 0,
|
|
9964
|
+
optimizeDeps: {
|
|
9965
|
+
disabled: true,
|
|
9966
|
+
entries: []
|
|
9967
|
+
}
|
|
9968
|
+
});
|
|
9969
|
+
}
|
|
11046
9970
|
return config;
|
|
11047
9971
|
},
|
|
11048
9972
|
async configResolved(viteConfig) {
|
|
@@ -11050,6 +9974,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11050
9974
|
const viteConfigTest = viteConfig.test || {};
|
|
11051
9975
|
if (viteConfigTest.watch === false)
|
|
11052
9976
|
viteConfigTest.run = true;
|
|
9977
|
+
if ("alias" in viteConfigTest)
|
|
9978
|
+
delete viteConfigTest.alias;
|
|
11053
9979
|
options = deepMerge({}, configDefaults, viteConfigTest, options);
|
|
11054
9980
|
options.api = resolveApiConfig(options);
|
|
11055
9981
|
const { PROD, DEV, ...envs } = viteConfig.env;
|
|
@@ -11066,7 +9992,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11066
9992
|
await ctx.setServer(options, server);
|
|
11067
9993
|
haveStarted = true;
|
|
11068
9994
|
if (options.api && options.watch)
|
|
11069
|
-
(await import('./chunk-api-setup.
|
|
9995
|
+
(await import('./chunk-api-setup.0cf2c96a.mjs')).setup(ctx);
|
|
11070
9996
|
} catch (err) {
|
|
11071
9997
|
ctx.logger.printError(err, true);
|
|
11072
9998
|
process.exit(1);
|
|
@@ -11078,6 +10004,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11078
10004
|
EnvReplacerPlugin(),
|
|
11079
10005
|
MocksPlugin(),
|
|
11080
10006
|
GlobalSetupPlugin(ctx),
|
|
10007
|
+
...options.browser ? await BrowserPlugin() : [],
|
|
11081
10008
|
CSSEnablerPlugin(ctx),
|
|
11082
10009
|
options.ui ? await UIPlugin() : null
|
|
11083
10010
|
].filter(notNullish);
|
|
@@ -11152,8 +10079,8 @@ function registerConsoleShortcuts(ctx) {
|
|
|
11152
10079
|
let rl;
|
|
11153
10080
|
function on() {
|
|
11154
10081
|
off();
|
|
11155
|
-
rl = require$$0$
|
|
11156
|
-
require$$0$
|
|
10082
|
+
rl = require$$0$2.createInterface({ input: process.stdin, escapeCodeTimeout: 50 });
|
|
10083
|
+
require$$0$2.emitKeypressEvents(process.stdin, rl);
|
|
11157
10084
|
if (process.stdin.isTTY)
|
|
11158
10085
|
process.stdin.setRawMode(true);
|
|
11159
10086
|
process.stdin.on("keypress", keypressHandler);
|
|
@@ -11175,7 +10102,10 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11175
10102
|
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
|
|
11176
10103
|
if (options.run)
|
|
11177
10104
|
options.watch = false;
|
|
11178
|
-
if (
|
|
10105
|
+
if (options.browser)
|
|
10106
|
+
options.threads = false;
|
|
10107
|
+
const root = resolve(options.root || process.cwd());
|
|
10108
|
+
if (!await ensurePackageInstalled("vite", root)) {
|
|
11179
10109
|
process.exitCode = 1;
|
|
11180
10110
|
return false;
|
|
11181
10111
|
}
|
|
@@ -11183,14 +10113,14 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11183
10113
|
options.coverage = { enabled: options.coverage };
|
|
11184
10114
|
const ctx = await createVitest(options, viteOverrides);
|
|
11185
10115
|
if (ctx.config.coverage.enabled) {
|
|
11186
|
-
if (!await ensurePackageInstalled("c8")) {
|
|
10116
|
+
if (!await ensurePackageInstalled("c8", root)) {
|
|
11187
10117
|
process.exitCode = 1;
|
|
11188
10118
|
return false;
|
|
11189
10119
|
}
|
|
11190
10120
|
}
|
|
11191
10121
|
if (ctx.config.environment && ctx.config.environment !== "node") {
|
|
11192
10122
|
const packageName = envPackageNames[ctx.config.environment];
|
|
11193
|
-
if (!await ensurePackageInstalled(packageName)) {
|
|
10123
|
+
if (!await ensurePackageInstalled(packageName, root)) {
|
|
11194
10124
|
process.exitCode = 1;
|
|
11195
10125
|
return false;
|
|
11196
10126
|
}
|