vitest 0.32.4 → 0.34.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 +0 -83
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +4 -8
- package/dist/child.js +43 -29
- package/dist/{chunk-api-setup.8f785c4a.js → chunk-api-setup.644415c3.js} +13 -7
- package/dist/{chunk-install-pkg.3fc886f2.js → chunk-install-pkg.dd70081b.js} +14 -13
- package/dist/{chunk-integrations-globals.0093e2ed.js → chunk-integrations-globals.877c84db.js} +7 -6
- package/dist/chunk-runtime-console.ea222ffb.js +108 -0
- package/dist/cli.js +15 -16
- package/dist/config.cjs +6 -5
- package/dist/config.d.ts +15 -19
- package/dist/config.js +6 -5
- package/dist/coverage.d.ts +3 -2
- package/dist/entry-vm.js +60 -0
- package/dist/entry.js +34 -213
- package/dist/environments.d.ts +3 -2
- package/dist/environments.js +4 -2
- package/dist/execute.js +15 -0
- package/dist/index.d.ts +12 -7
- package/dist/index.js +8 -7
- package/dist/loader.js +6 -4
- package/dist/node.d.ts +6 -53
- package/dist/node.js +17 -20
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +6 -5
- package/dist/{types-198fd1d9.d.ts → types-3c7dbfa5.d.ts} +139 -121
- package/dist/vendor-base.9c08bbd0.js +96 -0
- package/dist/{vendor-coverage.2e41927a.js → vendor-coverage.78040316.js} +1 -2
- package/dist/vendor-date.6e993429.js +50 -0
- package/dist/{vendor-environments.75f2b63d.js → vendor-environments.443ecd82.js} +202 -3
- package/dist/vendor-execute.9ab1c1a7.js +978 -0
- package/dist/{vendor-global.6795f91f.js → vendor-global.97e4527c.js} +2 -1
- package/dist/{vendor-index.23ac4e13.js → vendor-index.087d1af7.js} +2 -20
- package/dist/vendor-index.9378c9a4.js +89 -0
- package/dist/vendor-index.b271ebe4.js +92 -0
- package/dist/{vendor-index.2af39fbb.js → vendor-index.eff408fd.js} +2 -3
- package/dist/{vendor-cli-api.cb31e1db.js → vendor-node.00226ab1.js} +1671 -1882
- package/dist/{vendor-rpc.ad5b08c7.js → vendor-rpc.cbd8e972.js} +7 -4
- package/dist/{vendor-run-once.1fa85ba7.js → vendor-run-once.3e5ef7d7.js} +1 -2
- package/dist/vendor-source-map.e6c1997b.js +747 -0
- package/dist/{vendor-vi.dd6706cb.js → vendor-vi.271667ef.js} +26 -59
- package/dist/vm.js +114 -0
- package/dist/worker.js +39 -27
- package/execute.d.ts +1 -0
- package/package.json +14 -11
- package/suppress-warnings.cjs +2 -0
- package/dist/vendor-execute.3576af13.js +0 -421
- package/dist/vendor-index.cc463d9e.js +0 -189
- package/dist/vendor-tasks.f9d75aed.js +0 -14
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { resolve
|
|
2
|
-
import { E as EXIT_CODE_RESTART, c as configFiles, d as defaultPort, a as defaultBrowserPort, w as workspacesFiles, C as CONFIG_NAMES } from './vendor-constants.538d9b49.js';
|
|
3
|
-
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.2e41927a.js';
|
|
4
|
-
import { g as getEnvPackageName } from './vendor-environments.75f2b63d.js';
|
|
5
|
-
import url, { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
-
import c from 'picocolors';
|
|
7
|
-
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
8
|
-
import { a as isNode, b as relativePath, c as removeUndefinedValues, d as isWindows } from './vendor-index.23ac4e13.js';
|
|
9
|
-
import { isCI } from 'std-env';
|
|
1
|
+
import { resolve, relative, isAbsolute, dirname, basename, normalize, join, extname, toNamespacedPath } from 'pathe';
|
|
10
2
|
import { loadConfigFromFile, createServer, version as version$2, mergeConfig } from 'vite';
|
|
11
3
|
import path$a from 'node:path';
|
|
4
|
+
import url, { fileURLToPath, pathToFileURL } from 'node:url';
|
|
12
5
|
import process$1 from 'node:process';
|
|
13
6
|
import fs$8, { promises, existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { E as EXIT_CODE_RESTART, c as configFiles, d as defaultPort, a as defaultBrowserPort, w as workspacesFiles, C as CONFIG_NAMES } from './vendor-constants.538d9b49.js';
|
|
14
8
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
15
|
-
import f$1 from 'path';
|
|
16
9
|
import require$$0 from 'os';
|
|
10
|
+
import f$1 from 'path';
|
|
17
11
|
import require$$2 from 'util';
|
|
18
12
|
import require$$0$1 from 'stream';
|
|
19
13
|
import require$$2$1 from 'events';
|
|
20
14
|
import $ from 'fs';
|
|
15
|
+
import c from 'picocolors';
|
|
21
16
|
import { slash as slash$2, normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
22
17
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
23
18
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
24
19
|
import { ViteNodeServer } from 'vite-node/server';
|
|
20
|
+
import { a as isNode, r as relativePath, b as removeUndefinedValues, c as isWindows } from './vendor-index.087d1af7.js';
|
|
21
|
+
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.78040316.js';
|
|
25
22
|
import { d as distDir, r as rootDir } from './vendor-paths.84fc7a99.js';
|
|
26
23
|
import v8 from 'node:v8';
|
|
27
24
|
import { fork } from 'node:child_process';
|
|
28
|
-
import {
|
|
25
|
+
import { c as createBirpc } from './vendor-index.b271ebe4.js';
|
|
26
|
+
import { g as groupBy, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, a as stdout } from './vendor-base.9c08bbd0.js';
|
|
29
27
|
import { MessageChannel } from 'node:worker_threads';
|
|
30
|
-
import { cpus, hostname } from 'node:os';
|
|
28
|
+
import { cpus, hostname, totalmem } from 'node:os';
|
|
31
29
|
import Tinypool from 'tinypool';
|
|
32
|
-
import { createDefer, getSafeTimers, notNullish,
|
|
30
|
+
import { createDefer, getSafeTimers, notNullish, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
31
|
+
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
32
|
+
import { isCI } from 'std-env';
|
|
33
33
|
import { performance } from 'node:perf_hooks';
|
|
34
|
-
import { g as getFullName, h as hasFailedSnapshot } from './vendor-
|
|
34
|
+
import { g as getFullName, h as hasFailedSnapshot, p as parseErrorStacktrace, T as TraceMap, b as generatedPositionFor } from './vendor-source-map.e6c1997b.js';
|
|
35
35
|
import { getTests, hasFailed, getSuites, generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks } from '@vitest/runner/utils';
|
|
36
36
|
import { createRequire, builtinModules } from 'node:module';
|
|
37
37
|
import { createHash } from 'node:crypto';
|
|
@@ -42,6 +42,7 @@ import { parse as parse$4 } from 'acorn';
|
|
|
42
42
|
import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
43
43
|
import MagicString from 'magic-string';
|
|
44
44
|
import { stripLiteral } from 'strip-literal';
|
|
45
|
+
import { g as getEnvPackageName } from './vendor-environments.443ecd82.js';
|
|
45
46
|
import readline from 'node:readline';
|
|
46
47
|
import require$$0$2 from 'readline';
|
|
47
48
|
|
|
@@ -60,15 +61,13 @@ function _mergeNamespaces(n, m) {
|
|
|
60
61
|
return Object.freeze(n);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
var version$1 = "0.
|
|
64
|
+
var version$1 = "0.34.0";
|
|
64
65
|
|
|
65
66
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
66
|
-
async function ensurePackageInstalled(dependency, root
|
|
67
|
+
async function ensurePackageInstalled(dependency, root) {
|
|
67
68
|
if (isPackageExists(dependency, { paths: [root, __dirname$1] }))
|
|
68
69
|
return true;
|
|
69
70
|
const promptInstall = !isCI && process.stdout.isTTY;
|
|
70
|
-
if (errorMessage)
|
|
71
|
-
process.stderr.write(c.red(errorMessage));
|
|
72
71
|
process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
73
72
|
|
|
74
73
|
`));
|
|
@@ -81,7 +80,7 @@ async function ensurePackageInstalled(dependency, root, errorMessage) {
|
|
|
81
80
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
82
81
|
});
|
|
83
82
|
if (install) {
|
|
84
|
-
await (await import('./chunk-install-pkg.
|
|
83
|
+
await (await import('./chunk-install-pkg.dd70081b.js')).installPackage(dependency, { dev: true });
|
|
85
84
|
process.stderr.write(c.yellow(`
|
|
86
85
|
Package ${dependency} installed, re-run the command to start.
|
|
87
86
|
`));
|
|
@@ -374,92 +373,127 @@ var utils$k = {};
|
|
|
374
373
|
|
|
375
374
|
var array$1 = {};
|
|
376
375
|
|
|
377
|
-
Object.defineProperty(array$1, "__esModule", { value: true });
|
|
378
|
-
array$1.splitWhen = array$1.flatten = void 0;
|
|
379
|
-
function flatten(items) {
|
|
380
|
-
return items.reduce((collection, item) => [].concat(collection, item), []);
|
|
381
|
-
}
|
|
382
|
-
array$1.flatten = flatten;
|
|
383
|
-
function splitWhen(items, predicate) {
|
|
384
|
-
const result = [[]];
|
|
385
|
-
let groupIndex = 0;
|
|
386
|
-
for (const item of items) {
|
|
387
|
-
if (predicate(item)) {
|
|
388
|
-
groupIndex++;
|
|
389
|
-
result[groupIndex] = [];
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
result[groupIndex].push(item);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return result;
|
|
396
|
-
}
|
|
376
|
+
Object.defineProperty(array$1, "__esModule", { value: true });
|
|
377
|
+
array$1.splitWhen = array$1.flatten = void 0;
|
|
378
|
+
function flatten(items) {
|
|
379
|
+
return items.reduce((collection, item) => [].concat(collection, item), []);
|
|
380
|
+
}
|
|
381
|
+
array$1.flatten = flatten;
|
|
382
|
+
function splitWhen(items, predicate) {
|
|
383
|
+
const result = [[]];
|
|
384
|
+
let groupIndex = 0;
|
|
385
|
+
for (const item of items) {
|
|
386
|
+
if (predicate(item)) {
|
|
387
|
+
groupIndex++;
|
|
388
|
+
result[groupIndex] = [];
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
result[groupIndex].push(item);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return result;
|
|
395
|
+
}
|
|
397
396
|
array$1.splitWhen = splitWhen;
|
|
398
397
|
|
|
399
398
|
var errno$1 = {};
|
|
400
399
|
|
|
401
|
-
Object.defineProperty(errno$1, "__esModule", { value: true });
|
|
402
|
-
errno$1.isEnoentCodeError = void 0;
|
|
403
|
-
function isEnoentCodeError(error) {
|
|
404
|
-
return error.code === 'ENOENT';
|
|
405
|
-
}
|
|
400
|
+
Object.defineProperty(errno$1, "__esModule", { value: true });
|
|
401
|
+
errno$1.isEnoentCodeError = void 0;
|
|
402
|
+
function isEnoentCodeError(error) {
|
|
403
|
+
return error.code === 'ENOENT';
|
|
404
|
+
}
|
|
406
405
|
errno$1.isEnoentCodeError = isEnoentCodeError;
|
|
407
406
|
|
|
408
407
|
var fs$7 = {};
|
|
409
408
|
|
|
410
|
-
Object.defineProperty(fs$7, "__esModule", { value: true });
|
|
411
|
-
fs$7.createDirentFromStats = void 0;
|
|
412
|
-
let DirentFromStats$1 = class DirentFromStats {
|
|
413
|
-
constructor(name, stats) {
|
|
414
|
-
this.name = name;
|
|
415
|
-
this.isBlockDevice = stats.isBlockDevice.bind(stats);
|
|
416
|
-
this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
|
|
417
|
-
this.isDirectory = stats.isDirectory.bind(stats);
|
|
418
|
-
this.isFIFO = stats.isFIFO.bind(stats);
|
|
419
|
-
this.isFile = stats.isFile.bind(stats);
|
|
420
|
-
this.isSocket = stats.isSocket.bind(stats);
|
|
421
|
-
this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
function createDirentFromStats$1(name, stats) {
|
|
425
|
-
return new DirentFromStats$1(name, stats);
|
|
426
|
-
}
|
|
409
|
+
Object.defineProperty(fs$7, "__esModule", { value: true });
|
|
410
|
+
fs$7.createDirentFromStats = void 0;
|
|
411
|
+
let DirentFromStats$1 = class DirentFromStats {
|
|
412
|
+
constructor(name, stats) {
|
|
413
|
+
this.name = name;
|
|
414
|
+
this.isBlockDevice = stats.isBlockDevice.bind(stats);
|
|
415
|
+
this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
|
|
416
|
+
this.isDirectory = stats.isDirectory.bind(stats);
|
|
417
|
+
this.isFIFO = stats.isFIFO.bind(stats);
|
|
418
|
+
this.isFile = stats.isFile.bind(stats);
|
|
419
|
+
this.isSocket = stats.isSocket.bind(stats);
|
|
420
|
+
this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
function createDirentFromStats$1(name, stats) {
|
|
424
|
+
return new DirentFromStats$1(name, stats);
|
|
425
|
+
}
|
|
427
426
|
fs$7.createDirentFromStats = createDirentFromStats$1;
|
|
428
427
|
|
|
429
428
|
var path$9 = {};
|
|
430
429
|
|
|
431
|
-
Object.defineProperty(path$9, "__esModule", { value: true });
|
|
432
|
-
path$9.
|
|
433
|
-
const
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
430
|
+
Object.defineProperty(path$9, "__esModule", { value: true });
|
|
431
|
+
path$9.convertPosixPathToPattern = path$9.convertWindowsPathToPattern = path$9.convertPathToPattern = path$9.escapePosixPath = path$9.escapeWindowsPath = path$9.escape = path$9.removeLeadingDotSegment = path$9.makeAbsolute = path$9.unixify = void 0;
|
|
432
|
+
const os = require$$0;
|
|
433
|
+
const path$8 = f$1;
|
|
434
|
+
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
435
|
+
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
436
|
+
/**
|
|
437
|
+
* All non-escaped special characters.
|
|
438
|
+
* Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
|
|
439
|
+
* Windows: (){}, !+@ before (, ! at the beginning.
|
|
440
|
+
*/
|
|
441
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
442
|
+
const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
|
|
443
|
+
/**
|
|
444
|
+
* The device path (\\.\ or \\?\).
|
|
445
|
+
* https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
|
|
446
|
+
*/
|
|
447
|
+
const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
|
|
448
|
+
/**
|
|
449
|
+
* All backslashes except those escaping special characters.
|
|
450
|
+
* Windows: !()+@{}
|
|
451
|
+
* https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
|
452
|
+
*/
|
|
453
|
+
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
|
|
454
|
+
/**
|
|
455
|
+
* Designed to work only with simple paths: `dir\\file`.
|
|
456
|
+
*/
|
|
457
|
+
function unixify(filepath) {
|
|
458
|
+
return filepath.replace(/\\/g, '/');
|
|
459
|
+
}
|
|
460
|
+
path$9.unixify = unixify;
|
|
461
|
+
function makeAbsolute(cwd, filepath) {
|
|
462
|
+
return path$8.resolve(cwd, filepath);
|
|
463
|
+
}
|
|
464
|
+
path$9.makeAbsolute = makeAbsolute;
|
|
465
|
+
function removeLeadingDotSegment(entry) {
|
|
466
|
+
// We do not use `startsWith` because this is 10x slower than current implementation for some cases.
|
|
467
|
+
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
|
|
468
|
+
if (entry.charAt(0) === '.') {
|
|
469
|
+
const secondCharactery = entry.charAt(1);
|
|
470
|
+
if (secondCharactery === '/' || secondCharactery === '\\') {
|
|
471
|
+
return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return entry;
|
|
475
|
+
}
|
|
462
476
|
path$9.removeLeadingDotSegment = removeLeadingDotSegment;
|
|
477
|
+
path$9.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
|
|
478
|
+
function escapeWindowsPath(pattern) {
|
|
479
|
+
return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
|
480
|
+
}
|
|
481
|
+
path$9.escapeWindowsPath = escapeWindowsPath;
|
|
482
|
+
function escapePosixPath(pattern) {
|
|
483
|
+
return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
|
|
484
|
+
}
|
|
485
|
+
path$9.escapePosixPath = escapePosixPath;
|
|
486
|
+
path$9.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
|
|
487
|
+
function convertWindowsPathToPattern(filepath) {
|
|
488
|
+
return escapeWindowsPath(filepath)
|
|
489
|
+
.replace(DOS_DEVICE_PATH_RE, '//$1')
|
|
490
|
+
.replace(WINDOWS_BACKSLASHES_RE, '/');
|
|
491
|
+
}
|
|
492
|
+
path$9.convertWindowsPathToPattern = convertWindowsPathToPattern;
|
|
493
|
+
function convertPosixPathToPattern(filepath) {
|
|
494
|
+
return escapePosixPath(filepath);
|
|
495
|
+
}
|
|
496
|
+
path$9.convertPosixPathToPattern = convertPosixPathToPattern;
|
|
463
497
|
|
|
464
498
|
var pattern$1 = {};
|
|
465
499
|
|
|
@@ -492,7 +526,7 @@ var isExtglob$1 = function isExtglob(str) {
|
|
|
492
526
|
*/
|
|
493
527
|
|
|
494
528
|
var isExtglob = isExtglob$1;
|
|
495
|
-
var chars
|
|
529
|
+
var chars = { '{': '}', '(': ')', '[': ']'};
|
|
496
530
|
var strictCheck = function(str) {
|
|
497
531
|
if (str[0] === '!') {
|
|
498
532
|
return true;
|
|
@@ -565,7 +599,7 @@ var strictCheck = function(str) {
|
|
|
565
599
|
if (str[index] === '\\') {
|
|
566
600
|
var open = str[index + 1];
|
|
567
601
|
index += 2;
|
|
568
|
-
var close = chars
|
|
602
|
+
var close = chars[open];
|
|
569
603
|
|
|
570
604
|
if (close) {
|
|
571
605
|
var n = str.indexOf(close, index);
|
|
@@ -597,7 +631,7 @@ var relaxedCheck = function(str) {
|
|
|
597
631
|
if (str[index] === '\\') {
|
|
598
632
|
var open = str[index + 1];
|
|
599
633
|
index += 2;
|
|
600
|
-
var close = chars
|
|
634
|
+
var close = chars[open];
|
|
601
635
|
|
|
602
636
|
if (close) {
|
|
603
637
|
var n = str.indexOf(close, index);
|
|
@@ -1138,7 +1172,7 @@ const toRegexRange = toRegexRange_1;
|
|
|
1138
1172
|
|
|
1139
1173
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
1140
1174
|
|
|
1141
|
-
const transform
|
|
1175
|
+
const transform = toNumber => {
|
|
1142
1176
|
return value => toNumber === true ? Number(value) : String(value);
|
|
1143
1177
|
};
|
|
1144
1178
|
|
|
@@ -1275,7 +1309,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
|
1275
1309
|
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
|
1276
1310
|
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
|
1277
1311
|
let toNumber = padded === false && stringify$3(start, end, options) === false;
|
|
1278
|
-
let format = options.transform || transform
|
|
1312
|
+
let format = options.transform || transform(toNumber);
|
|
1279
1313
|
|
|
1280
1314
|
if (options.toRegex && step === 1) {
|
|
1281
1315
|
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
|
@@ -4633,174 +4667,193 @@ var micromatch_1 = micromatch$1;
|
|
|
4633
4667
|
|
|
4634
4668
|
var mm = /*@__PURE__*/getDefaultExportFromCjs(micromatch_1);
|
|
4635
4669
|
|
|
4636
|
-
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4637
|
-
pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
|
|
4638
|
-
const path$5 = f$1;
|
|
4639
|
-
const globParent = globParent$1;
|
|
4640
|
-
const micromatch = micromatch_1;
|
|
4641
|
-
const GLOBSTAR = '**';
|
|
4642
|
-
const ESCAPE_SYMBOL = '\\';
|
|
4643
|
-
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
|
4644
|
-
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
|
|
4645
|
-
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
|
|
4646
|
-
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
|
|
4647
|
-
const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
}
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
return
|
|
4757
|
-
}
|
|
4758
|
-
pattern$1.
|
|
4759
|
-
function
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4670
|
+
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4671
|
+
pattern$1.removeDuplicateSlashes = pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
|
|
4672
|
+
const path$5 = f$1;
|
|
4673
|
+
const globParent = globParent$1;
|
|
4674
|
+
const micromatch = micromatch_1;
|
|
4675
|
+
const GLOBSTAR = '**';
|
|
4676
|
+
const ESCAPE_SYMBOL = '\\';
|
|
4677
|
+
const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
|
4678
|
+
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
|
|
4679
|
+
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
|
|
4680
|
+
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
|
|
4681
|
+
const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
|
|
4682
|
+
/**
|
|
4683
|
+
* Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
|
|
4684
|
+
* The latter is due to the presence of the device path at the beginning of the UNC path.
|
|
4685
|
+
*/
|
|
4686
|
+
const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
|
|
4687
|
+
function isStaticPattern(pattern, options = {}) {
|
|
4688
|
+
return !isDynamicPattern(pattern, options);
|
|
4689
|
+
}
|
|
4690
|
+
pattern$1.isStaticPattern = isStaticPattern;
|
|
4691
|
+
function isDynamicPattern(pattern, options = {}) {
|
|
4692
|
+
/**
|
|
4693
|
+
* A special case with an empty string is necessary for matching patterns that start with a forward slash.
|
|
4694
|
+
* An empty string cannot be a dynamic pattern.
|
|
4695
|
+
* For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
|
|
4696
|
+
*/
|
|
4697
|
+
if (pattern === '') {
|
|
4698
|
+
return false;
|
|
4699
|
+
}
|
|
4700
|
+
/**
|
|
4701
|
+
* When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
|
|
4702
|
+
* filepath directly (without read directory).
|
|
4703
|
+
*/
|
|
4704
|
+
if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
|
|
4705
|
+
return true;
|
|
4706
|
+
}
|
|
4707
|
+
if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
|
|
4708
|
+
return true;
|
|
4709
|
+
}
|
|
4710
|
+
if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
|
|
4711
|
+
return true;
|
|
4712
|
+
}
|
|
4713
|
+
if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
|
|
4714
|
+
return true;
|
|
4715
|
+
}
|
|
4716
|
+
return false;
|
|
4717
|
+
}
|
|
4718
|
+
pattern$1.isDynamicPattern = isDynamicPattern;
|
|
4719
|
+
function hasBraceExpansion(pattern) {
|
|
4720
|
+
const openingBraceIndex = pattern.indexOf('{');
|
|
4721
|
+
if (openingBraceIndex === -1) {
|
|
4722
|
+
return false;
|
|
4723
|
+
}
|
|
4724
|
+
const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
|
|
4725
|
+
if (closingBraceIndex === -1) {
|
|
4726
|
+
return false;
|
|
4727
|
+
}
|
|
4728
|
+
const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
|
|
4729
|
+
return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
|
|
4730
|
+
}
|
|
4731
|
+
function convertToPositivePattern(pattern) {
|
|
4732
|
+
return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
|
|
4733
|
+
}
|
|
4734
|
+
pattern$1.convertToPositivePattern = convertToPositivePattern;
|
|
4735
|
+
function convertToNegativePattern(pattern) {
|
|
4736
|
+
return '!' + pattern;
|
|
4737
|
+
}
|
|
4738
|
+
pattern$1.convertToNegativePattern = convertToNegativePattern;
|
|
4739
|
+
function isNegativePattern(pattern) {
|
|
4740
|
+
return pattern.startsWith('!') && pattern[1] !== '(';
|
|
4741
|
+
}
|
|
4742
|
+
pattern$1.isNegativePattern = isNegativePattern;
|
|
4743
|
+
function isPositivePattern(pattern) {
|
|
4744
|
+
return !isNegativePattern(pattern);
|
|
4745
|
+
}
|
|
4746
|
+
pattern$1.isPositivePattern = isPositivePattern;
|
|
4747
|
+
function getNegativePatterns(patterns) {
|
|
4748
|
+
return patterns.filter(isNegativePattern);
|
|
4749
|
+
}
|
|
4750
|
+
pattern$1.getNegativePatterns = getNegativePatterns;
|
|
4751
|
+
function getPositivePatterns$1(patterns) {
|
|
4752
|
+
return patterns.filter(isPositivePattern);
|
|
4753
|
+
}
|
|
4754
|
+
pattern$1.getPositivePatterns = getPositivePatterns$1;
|
|
4755
|
+
/**
|
|
4756
|
+
* Returns patterns that can be applied inside the current directory.
|
|
4757
|
+
*
|
|
4758
|
+
* @example
|
|
4759
|
+
* // ['./*', '*', 'a/*']
|
|
4760
|
+
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
4761
|
+
*/
|
|
4762
|
+
function getPatternsInsideCurrentDirectory(patterns) {
|
|
4763
|
+
return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
|
|
4764
|
+
}
|
|
4765
|
+
pattern$1.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
|
|
4766
|
+
/**
|
|
4767
|
+
* Returns patterns to be expanded relative to (outside) the current directory.
|
|
4768
|
+
*
|
|
4769
|
+
* @example
|
|
4770
|
+
* // ['../*', './../*']
|
|
4771
|
+
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
|
|
4772
|
+
*/
|
|
4773
|
+
function getPatternsOutsideCurrentDirectory(patterns) {
|
|
4774
|
+
return patterns.filter(isPatternRelatedToParentDirectory);
|
|
4775
|
+
}
|
|
4776
|
+
pattern$1.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
|
|
4777
|
+
function isPatternRelatedToParentDirectory(pattern) {
|
|
4778
|
+
return pattern.startsWith('..') || pattern.startsWith('./..');
|
|
4779
|
+
}
|
|
4780
|
+
pattern$1.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
|
|
4781
|
+
function getBaseDirectory(pattern) {
|
|
4782
|
+
return globParent(pattern, { flipBackslashes: false });
|
|
4783
|
+
}
|
|
4784
|
+
pattern$1.getBaseDirectory = getBaseDirectory;
|
|
4785
|
+
function hasGlobStar(pattern) {
|
|
4786
|
+
return pattern.includes(GLOBSTAR);
|
|
4787
|
+
}
|
|
4788
|
+
pattern$1.hasGlobStar = hasGlobStar;
|
|
4789
|
+
function endsWithSlashGlobStar(pattern) {
|
|
4790
|
+
return pattern.endsWith('/' + GLOBSTAR);
|
|
4791
|
+
}
|
|
4792
|
+
pattern$1.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
4793
|
+
function isAffectDepthOfReadingPattern(pattern) {
|
|
4794
|
+
const basename = path$5.basename(pattern);
|
|
4795
|
+
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
4796
|
+
}
|
|
4797
|
+
pattern$1.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
4798
|
+
function expandPatternsWithBraceExpansion(patterns) {
|
|
4799
|
+
return patterns.reduce((collection, pattern) => {
|
|
4800
|
+
return collection.concat(expandBraceExpansion(pattern));
|
|
4801
|
+
}, []);
|
|
4802
|
+
}
|
|
4803
|
+
pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
|
4804
|
+
function expandBraceExpansion(pattern) {
|
|
4805
|
+
const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
|
|
4806
|
+
/**
|
|
4807
|
+
* Sort the patterns by length so that the same depth patterns are processed side by side.
|
|
4808
|
+
* `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
|
|
4809
|
+
*/
|
|
4810
|
+
patterns.sort((a, b) => a.length - b.length);
|
|
4811
|
+
/**
|
|
4812
|
+
* Micromatch can return an empty string in the case of patterns like `{a,}`.
|
|
4813
|
+
*/
|
|
4814
|
+
return patterns.filter((pattern) => pattern !== '');
|
|
4815
|
+
}
|
|
4816
|
+
pattern$1.expandBraceExpansion = expandBraceExpansion;
|
|
4817
|
+
function getPatternParts(pattern, options) {
|
|
4818
|
+
let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
|
|
4819
|
+
/**
|
|
4820
|
+
* The scan method returns an empty array in some cases.
|
|
4821
|
+
* See micromatch/picomatch#58 for more details.
|
|
4822
|
+
*/
|
|
4823
|
+
if (parts.length === 0) {
|
|
4824
|
+
parts = [pattern];
|
|
4825
|
+
}
|
|
4826
|
+
/**
|
|
4827
|
+
* The scan method does not return an empty part for the pattern with a forward slash.
|
|
4828
|
+
* This is another part of micromatch/picomatch#58.
|
|
4829
|
+
*/
|
|
4830
|
+
if (parts[0].startsWith('/')) {
|
|
4831
|
+
parts[0] = parts[0].slice(1);
|
|
4832
|
+
parts.unshift('');
|
|
4833
|
+
}
|
|
4834
|
+
return parts;
|
|
4835
|
+
}
|
|
4836
|
+
pattern$1.getPatternParts = getPatternParts;
|
|
4837
|
+
function makeRe(pattern, options) {
|
|
4838
|
+
return micromatch.makeRe(pattern, options);
|
|
4839
|
+
}
|
|
4840
|
+
pattern$1.makeRe = makeRe;
|
|
4841
|
+
function convertPatternsToRe(patterns, options) {
|
|
4842
|
+
return patterns.map((pattern) => makeRe(pattern, options));
|
|
4843
|
+
}
|
|
4844
|
+
pattern$1.convertPatternsToRe = convertPatternsToRe;
|
|
4845
|
+
function matchAny(entry, patternsRe) {
|
|
4846
|
+
return patternsRe.some((patternRe) => patternRe.test(entry));
|
|
4847
|
+
}
|
|
4803
4848
|
pattern$1.matchAny = matchAny;
|
|
4849
|
+
/**
|
|
4850
|
+
* This package only works with forward slashes as a path separator.
|
|
4851
|
+
* Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
|
|
4852
|
+
*/
|
|
4853
|
+
function removeDuplicateSlashes(pattern) {
|
|
4854
|
+
return pattern.replace(DOUBLE_SLASH_RE, '/');
|
|
4855
|
+
}
|
|
4856
|
+
pattern$1.removeDuplicateSlashes = removeDuplicateSlashes;
|
|
4804
4857
|
|
|
4805
4858
|
var stream$4 = {};
|
|
4806
4859
|
|
|
@@ -4948,156 +5001,163 @@ function pauseStreams (streams, options) {
|
|
|
4948
5001
|
return streams
|
|
4949
5002
|
}
|
|
4950
5003
|
|
|
4951
|
-
Object.defineProperty(stream$4, "__esModule", { value: true });
|
|
4952
|
-
stream$4.merge = void 0;
|
|
4953
|
-
const merge2 = merge2_1;
|
|
4954
|
-
function merge(streams) {
|
|
4955
|
-
const mergedStream = merge2(streams);
|
|
4956
|
-
streams.forEach((stream) => {
|
|
4957
|
-
stream.once('error', (error) => mergedStream.emit('error', error));
|
|
4958
|
-
});
|
|
4959
|
-
mergedStream.once('close', () => propagateCloseEventToSources(streams));
|
|
4960
|
-
mergedStream.once('end', () => propagateCloseEventToSources(streams));
|
|
4961
|
-
return mergedStream;
|
|
4962
|
-
}
|
|
4963
|
-
stream$4.merge = merge;
|
|
4964
|
-
function propagateCloseEventToSources(streams) {
|
|
4965
|
-
streams.forEach((stream) => stream.emit('close'));
|
|
5004
|
+
Object.defineProperty(stream$4, "__esModule", { value: true });
|
|
5005
|
+
stream$4.merge = void 0;
|
|
5006
|
+
const merge2 = merge2_1;
|
|
5007
|
+
function merge(streams) {
|
|
5008
|
+
const mergedStream = merge2(streams);
|
|
5009
|
+
streams.forEach((stream) => {
|
|
5010
|
+
stream.once('error', (error) => mergedStream.emit('error', error));
|
|
5011
|
+
});
|
|
5012
|
+
mergedStream.once('close', () => propagateCloseEventToSources(streams));
|
|
5013
|
+
mergedStream.once('end', () => propagateCloseEventToSources(streams));
|
|
5014
|
+
return mergedStream;
|
|
5015
|
+
}
|
|
5016
|
+
stream$4.merge = merge;
|
|
5017
|
+
function propagateCloseEventToSources(streams) {
|
|
5018
|
+
streams.forEach((stream) => stream.emit('close'));
|
|
4966
5019
|
}
|
|
4967
5020
|
|
|
4968
5021
|
var string$1 = {};
|
|
4969
5022
|
|
|
4970
|
-
Object.defineProperty(string$1, "__esModule", { value: true });
|
|
4971
|
-
string$1.isEmpty = string$1.isString = void 0;
|
|
4972
|
-
function isString(input) {
|
|
4973
|
-
return typeof input === 'string';
|
|
4974
|
-
}
|
|
4975
|
-
string$1.isString = isString;
|
|
4976
|
-
function isEmpty(input) {
|
|
4977
|
-
return input === '';
|
|
4978
|
-
}
|
|
5023
|
+
Object.defineProperty(string$1, "__esModule", { value: true });
|
|
5024
|
+
string$1.isEmpty = string$1.isString = void 0;
|
|
5025
|
+
function isString(input) {
|
|
5026
|
+
return typeof input === 'string';
|
|
5027
|
+
}
|
|
5028
|
+
string$1.isString = isString;
|
|
5029
|
+
function isEmpty(input) {
|
|
5030
|
+
return input === '';
|
|
5031
|
+
}
|
|
4979
5032
|
string$1.isEmpty = isEmpty;
|
|
4980
5033
|
|
|
4981
|
-
Object.defineProperty(utils$k, "__esModule", { value: true });
|
|
4982
|
-
utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
|
|
4983
|
-
const array = array$1;
|
|
4984
|
-
utils$k.array = array;
|
|
4985
|
-
const errno = errno$1;
|
|
4986
|
-
utils$k.errno = errno;
|
|
4987
|
-
const fs$6 = fs$7;
|
|
4988
|
-
utils$k.fs = fs$6;
|
|
4989
|
-
const path$4 = path$9;
|
|
4990
|
-
utils$k.path = path$4;
|
|
4991
|
-
const pattern = pattern$1;
|
|
4992
|
-
utils$k.pattern = pattern;
|
|
4993
|
-
const stream$3 = stream$4;
|
|
4994
|
-
utils$k.stream = stream$3;
|
|
4995
|
-
const string = string$1;
|
|
5034
|
+
Object.defineProperty(utils$k, "__esModule", { value: true });
|
|
5035
|
+
utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
|
|
5036
|
+
const array = array$1;
|
|
5037
|
+
utils$k.array = array;
|
|
5038
|
+
const errno = errno$1;
|
|
5039
|
+
utils$k.errno = errno;
|
|
5040
|
+
const fs$6 = fs$7;
|
|
5041
|
+
utils$k.fs = fs$6;
|
|
5042
|
+
const path$4 = path$9;
|
|
5043
|
+
utils$k.path = path$4;
|
|
5044
|
+
const pattern = pattern$1;
|
|
5045
|
+
utils$k.pattern = pattern;
|
|
5046
|
+
const stream$3 = stream$4;
|
|
5047
|
+
utils$k.stream = stream$3;
|
|
5048
|
+
const string = string$1;
|
|
4996
5049
|
utils$k.string = string;
|
|
4997
5050
|
|
|
4998
|
-
Object.defineProperty(tasks, "__esModule", { value: true });
|
|
4999
|
-
tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
|
|
5000
|
-
const utils$a = utils$k;
|
|
5001
|
-
function generate(
|
|
5002
|
-
const
|
|
5003
|
-
const
|
|
5004
|
-
const
|
|
5005
|
-
const
|
|
5006
|
-
const
|
|
5007
|
-
const
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
*
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
}
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
function
|
|
5048
|
-
const
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
}
|
|
5066
|
-
tasks.
|
|
5067
|
-
function
|
|
5068
|
-
return
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
}
|
|
5051
|
+
Object.defineProperty(tasks, "__esModule", { value: true });
|
|
5052
|
+
tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
|
|
5053
|
+
const utils$a = utils$k;
|
|
5054
|
+
function generate(input, settings) {
|
|
5055
|
+
const patterns = processPatterns(input, settings);
|
|
5056
|
+
const ignore = processPatterns(settings.ignore, settings);
|
|
5057
|
+
const positivePatterns = getPositivePatterns(patterns);
|
|
5058
|
+
const negativePatterns = getNegativePatternsAsPositive(patterns, ignore);
|
|
5059
|
+
const staticPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isStaticPattern(pattern, settings));
|
|
5060
|
+
const dynamicPatterns = positivePatterns.filter((pattern) => utils$a.pattern.isDynamicPattern(pattern, settings));
|
|
5061
|
+
const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false);
|
|
5062
|
+
const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true);
|
|
5063
|
+
return staticTasks.concat(dynamicTasks);
|
|
5064
|
+
}
|
|
5065
|
+
tasks.generate = generate;
|
|
5066
|
+
function processPatterns(input, settings) {
|
|
5067
|
+
let patterns = input;
|
|
5068
|
+
/**
|
|
5069
|
+
* The original pattern like `{,*,**,a/*}` can lead to problems checking the depth when matching entry
|
|
5070
|
+
* and some problems with the micromatch package (see fast-glob issues: #365, #394).
|
|
5071
|
+
*
|
|
5072
|
+
* To solve this problem, we expand all patterns containing brace expansion. This can lead to a slight slowdown
|
|
5073
|
+
* in matching in the case of a large set of patterns after expansion.
|
|
5074
|
+
*/
|
|
5075
|
+
if (settings.braceExpansion) {
|
|
5076
|
+
patterns = utils$a.pattern.expandPatternsWithBraceExpansion(patterns);
|
|
5077
|
+
}
|
|
5078
|
+
/**
|
|
5079
|
+
* If the `baseNameMatch` option is enabled, we must add globstar to patterns, so that they can be used
|
|
5080
|
+
* at any nesting level.
|
|
5081
|
+
*
|
|
5082
|
+
* We do this here, because otherwise we have to complicate the filtering logic. For example, we need to change
|
|
5083
|
+
* the pattern in the filter before creating a regular expression. There is no need to change the patterns
|
|
5084
|
+
* in the application. Only on the input.
|
|
5085
|
+
*/
|
|
5086
|
+
if (settings.baseNameMatch) {
|
|
5087
|
+
patterns = patterns.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`);
|
|
5088
|
+
}
|
|
5089
|
+
/**
|
|
5090
|
+
* This method also removes duplicate slashes that may have been in the pattern or formed as a result of expansion.
|
|
5091
|
+
*/
|
|
5092
|
+
return patterns.map((pattern) => utils$a.pattern.removeDuplicateSlashes(pattern));
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Returns tasks grouped by basic pattern directories.
|
|
5096
|
+
*
|
|
5097
|
+
* Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately.
|
|
5098
|
+
* This is necessary because directory traversal starts at the base directory and goes deeper.
|
|
5099
|
+
*/
|
|
5100
|
+
function convertPatternsToTasks(positive, negative, dynamic) {
|
|
5101
|
+
const tasks = [];
|
|
5102
|
+
const patternsOutsideCurrentDirectory = utils$a.pattern.getPatternsOutsideCurrentDirectory(positive);
|
|
5103
|
+
const patternsInsideCurrentDirectory = utils$a.pattern.getPatternsInsideCurrentDirectory(positive);
|
|
5104
|
+
const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
|
|
5105
|
+
const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
|
|
5106
|
+
tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
|
|
5107
|
+
/*
|
|
5108
|
+
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
|
|
5109
|
+
* into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest.
|
|
5110
|
+
*/
|
|
5111
|
+
if ('.' in insideCurrentDirectoryGroup) {
|
|
5112
|
+
tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic));
|
|
5113
|
+
}
|
|
5114
|
+
else {
|
|
5115
|
+
tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic));
|
|
5116
|
+
}
|
|
5117
|
+
return tasks;
|
|
5118
|
+
}
|
|
5119
|
+
tasks.convertPatternsToTasks = convertPatternsToTasks;
|
|
5120
|
+
function getPositivePatterns(patterns) {
|
|
5121
|
+
return utils$a.pattern.getPositivePatterns(patterns);
|
|
5122
|
+
}
|
|
5123
|
+
tasks.getPositivePatterns = getPositivePatterns;
|
|
5124
|
+
function getNegativePatternsAsPositive(patterns, ignore) {
|
|
5125
|
+
const negative = utils$a.pattern.getNegativePatterns(patterns).concat(ignore);
|
|
5126
|
+
const positive = negative.map(utils$a.pattern.convertToPositivePattern);
|
|
5127
|
+
return positive;
|
|
5128
|
+
}
|
|
5129
|
+
tasks.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
|
|
5130
|
+
function groupPatternsByBaseDirectory(patterns) {
|
|
5131
|
+
const group = {};
|
|
5132
|
+
return patterns.reduce((collection, pattern) => {
|
|
5133
|
+
const base = utils$a.pattern.getBaseDirectory(pattern);
|
|
5134
|
+
if (base in collection) {
|
|
5135
|
+
collection[base].push(pattern);
|
|
5136
|
+
}
|
|
5137
|
+
else {
|
|
5138
|
+
collection[base] = [pattern];
|
|
5139
|
+
}
|
|
5140
|
+
return collection;
|
|
5141
|
+
}, group);
|
|
5142
|
+
}
|
|
5143
|
+
tasks.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
|
|
5144
|
+
function convertPatternGroupsToTasks(positive, negative, dynamic) {
|
|
5145
|
+
return Object.keys(positive).map((base) => {
|
|
5146
|
+
return convertPatternGroupToTask(base, positive[base], negative, dynamic);
|
|
5147
|
+
});
|
|
5148
|
+
}
|
|
5149
|
+
tasks.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
|
|
5150
|
+
function convertPatternGroupToTask(base, positive, negative, dynamic) {
|
|
5151
|
+
return {
|
|
5152
|
+
dynamic,
|
|
5153
|
+
positive,
|
|
5154
|
+
negative,
|
|
5155
|
+
base,
|
|
5156
|
+
patterns: [].concat(positive, negative.map(utils$a.pattern.convertToNegativePattern))
|
|
5157
|
+
};
|
|
5158
|
+
}
|
|
5076
5159
|
tasks.convertPatternGroupToTask = convertPatternGroupToTask;
|
|
5077
5160
|
|
|
5078
|
-
var patterns = {};
|
|
5079
|
-
|
|
5080
|
-
Object.defineProperty(patterns, "__esModule", { value: true });
|
|
5081
|
-
patterns.removeDuplicateSlashes = patterns.transform = void 0;
|
|
5082
|
-
/**
|
|
5083
|
-
* Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
|
|
5084
|
-
* The latter is due to the presence of the device path at the beginning of the UNC path.
|
|
5085
|
-
* @todo rewrite to negative lookbehind with the next major release.
|
|
5086
|
-
*/
|
|
5087
|
-
const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
|
|
5088
|
-
function transform(patterns) {
|
|
5089
|
-
return patterns.map((pattern) => removeDuplicateSlashes(pattern));
|
|
5090
|
-
}
|
|
5091
|
-
patterns.transform = transform;
|
|
5092
|
-
/**
|
|
5093
|
-
* This package only works with forward slashes as a path separator.
|
|
5094
|
-
* Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
|
|
5095
|
-
*/
|
|
5096
|
-
function removeDuplicateSlashes(pattern) {
|
|
5097
|
-
return pattern.replace(DOUBLE_SLASH_RE, '/');
|
|
5098
|
-
}
|
|
5099
|
-
patterns.removeDuplicateSlashes = removeDuplicateSlashes;
|
|
5100
|
-
|
|
5101
5161
|
var async$7 = {};
|
|
5102
5162
|
|
|
5103
5163
|
var async$6 = {};
|
|
@@ -6271,129 +6331,129 @@ function getSettings(settingsOrOptions = {}) {
|
|
|
6271
6331
|
|
|
6272
6332
|
var reader = {};
|
|
6273
6333
|
|
|
6274
|
-
Object.defineProperty(reader, "__esModule", { value: true });
|
|
6275
|
-
const path$1 = f$1;
|
|
6276
|
-
const fsStat$2 = out$1;
|
|
6277
|
-
const utils$6 = utils$k;
|
|
6278
|
-
class Reader {
|
|
6279
|
-
constructor(_settings) {
|
|
6280
|
-
this._settings = _settings;
|
|
6281
|
-
this._fsStatSettings = new fsStat$2.Settings({
|
|
6282
|
-
followSymbolicLink: this._settings.followSymbolicLinks,
|
|
6283
|
-
fs: this._settings.fs,
|
|
6284
|
-
throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
|
|
6285
|
-
});
|
|
6286
|
-
}
|
|
6287
|
-
_getFullEntryPath(filepath) {
|
|
6288
|
-
return path$1.resolve(this._settings.cwd, filepath);
|
|
6289
|
-
}
|
|
6290
|
-
_makeEntry(stats, pattern) {
|
|
6291
|
-
const entry = {
|
|
6292
|
-
name: pattern,
|
|
6293
|
-
path: pattern,
|
|
6294
|
-
dirent: utils$6.fs.createDirentFromStats(pattern, stats)
|
|
6295
|
-
};
|
|
6296
|
-
if (this._settings.stats) {
|
|
6297
|
-
entry.stats = stats;
|
|
6298
|
-
}
|
|
6299
|
-
return entry;
|
|
6300
|
-
}
|
|
6301
|
-
_isFatalError(error) {
|
|
6302
|
-
return !utils$6.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
|
|
6303
|
-
}
|
|
6304
|
-
}
|
|
6334
|
+
Object.defineProperty(reader, "__esModule", { value: true });
|
|
6335
|
+
const path$1 = f$1;
|
|
6336
|
+
const fsStat$2 = out$1;
|
|
6337
|
+
const utils$6 = utils$k;
|
|
6338
|
+
class Reader {
|
|
6339
|
+
constructor(_settings) {
|
|
6340
|
+
this._settings = _settings;
|
|
6341
|
+
this._fsStatSettings = new fsStat$2.Settings({
|
|
6342
|
+
followSymbolicLink: this._settings.followSymbolicLinks,
|
|
6343
|
+
fs: this._settings.fs,
|
|
6344
|
+
throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks
|
|
6345
|
+
});
|
|
6346
|
+
}
|
|
6347
|
+
_getFullEntryPath(filepath) {
|
|
6348
|
+
return path$1.resolve(this._settings.cwd, filepath);
|
|
6349
|
+
}
|
|
6350
|
+
_makeEntry(stats, pattern) {
|
|
6351
|
+
const entry = {
|
|
6352
|
+
name: pattern,
|
|
6353
|
+
path: pattern,
|
|
6354
|
+
dirent: utils$6.fs.createDirentFromStats(pattern, stats)
|
|
6355
|
+
};
|
|
6356
|
+
if (this._settings.stats) {
|
|
6357
|
+
entry.stats = stats;
|
|
6358
|
+
}
|
|
6359
|
+
return entry;
|
|
6360
|
+
}
|
|
6361
|
+
_isFatalError(error) {
|
|
6362
|
+
return !utils$6.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
|
|
6363
|
+
}
|
|
6364
|
+
}
|
|
6305
6365
|
reader.default = Reader;
|
|
6306
6366
|
|
|
6307
6367
|
var stream$1 = {};
|
|
6308
6368
|
|
|
6309
|
-
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
6310
|
-
const stream_1$3 = require$$0$1;
|
|
6311
|
-
const fsStat$1 = out$1;
|
|
6312
|
-
const fsWalk$2 = out$3;
|
|
6313
|
-
const reader_1$2 = reader;
|
|
6314
|
-
class ReaderStream extends reader_1$2.default {
|
|
6315
|
-
constructor() {
|
|
6316
|
-
super(...arguments);
|
|
6317
|
-
this._walkStream = fsWalk$2.walkStream;
|
|
6318
|
-
this._stat = fsStat$1.stat;
|
|
6319
|
-
}
|
|
6320
|
-
dynamic(root, options) {
|
|
6321
|
-
return this._walkStream(root, options);
|
|
6322
|
-
}
|
|
6323
|
-
static(patterns, options) {
|
|
6324
|
-
const filepaths = patterns.map(this._getFullEntryPath, this);
|
|
6325
|
-
const stream = new stream_1$3.PassThrough({ objectMode: true });
|
|
6326
|
-
stream._write = (index, _enc, done) => {
|
|
6327
|
-
return this._getEntry(filepaths[index], patterns[index], options)
|
|
6328
|
-
.then((entry) => {
|
|
6329
|
-
if (entry !== null && options.entryFilter(entry)) {
|
|
6330
|
-
stream.push(entry);
|
|
6331
|
-
}
|
|
6332
|
-
if (index === filepaths.length - 1) {
|
|
6333
|
-
stream.end();
|
|
6334
|
-
}
|
|
6335
|
-
done();
|
|
6336
|
-
})
|
|
6337
|
-
.catch(done);
|
|
6338
|
-
};
|
|
6339
|
-
for (let i = 0; i < filepaths.length; i++) {
|
|
6340
|
-
stream.write(i);
|
|
6341
|
-
}
|
|
6342
|
-
return stream;
|
|
6343
|
-
}
|
|
6344
|
-
_getEntry(filepath, pattern, options) {
|
|
6345
|
-
return this._getStat(filepath)
|
|
6346
|
-
.then((stats) => this._makeEntry(stats, pattern))
|
|
6347
|
-
.catch((error) => {
|
|
6348
|
-
if (options.errorFilter(error)) {
|
|
6349
|
-
return null;
|
|
6350
|
-
}
|
|
6351
|
-
throw error;
|
|
6352
|
-
});
|
|
6353
|
-
}
|
|
6354
|
-
_getStat(filepath) {
|
|
6355
|
-
return new Promise((resolve, reject) => {
|
|
6356
|
-
this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
|
6357
|
-
return error === null ? resolve(stats) : reject(error);
|
|
6358
|
-
});
|
|
6359
|
-
});
|
|
6360
|
-
}
|
|
6361
|
-
}
|
|
6369
|
+
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
6370
|
+
const stream_1$3 = require$$0$1;
|
|
6371
|
+
const fsStat$1 = out$1;
|
|
6372
|
+
const fsWalk$2 = out$3;
|
|
6373
|
+
const reader_1$2 = reader;
|
|
6374
|
+
class ReaderStream extends reader_1$2.default {
|
|
6375
|
+
constructor() {
|
|
6376
|
+
super(...arguments);
|
|
6377
|
+
this._walkStream = fsWalk$2.walkStream;
|
|
6378
|
+
this._stat = fsStat$1.stat;
|
|
6379
|
+
}
|
|
6380
|
+
dynamic(root, options) {
|
|
6381
|
+
return this._walkStream(root, options);
|
|
6382
|
+
}
|
|
6383
|
+
static(patterns, options) {
|
|
6384
|
+
const filepaths = patterns.map(this._getFullEntryPath, this);
|
|
6385
|
+
const stream = new stream_1$3.PassThrough({ objectMode: true });
|
|
6386
|
+
stream._write = (index, _enc, done) => {
|
|
6387
|
+
return this._getEntry(filepaths[index], patterns[index], options)
|
|
6388
|
+
.then((entry) => {
|
|
6389
|
+
if (entry !== null && options.entryFilter(entry)) {
|
|
6390
|
+
stream.push(entry);
|
|
6391
|
+
}
|
|
6392
|
+
if (index === filepaths.length - 1) {
|
|
6393
|
+
stream.end();
|
|
6394
|
+
}
|
|
6395
|
+
done();
|
|
6396
|
+
})
|
|
6397
|
+
.catch(done);
|
|
6398
|
+
};
|
|
6399
|
+
for (let i = 0; i < filepaths.length; i++) {
|
|
6400
|
+
stream.write(i);
|
|
6401
|
+
}
|
|
6402
|
+
return stream;
|
|
6403
|
+
}
|
|
6404
|
+
_getEntry(filepath, pattern, options) {
|
|
6405
|
+
return this._getStat(filepath)
|
|
6406
|
+
.then((stats) => this._makeEntry(stats, pattern))
|
|
6407
|
+
.catch((error) => {
|
|
6408
|
+
if (options.errorFilter(error)) {
|
|
6409
|
+
return null;
|
|
6410
|
+
}
|
|
6411
|
+
throw error;
|
|
6412
|
+
});
|
|
6413
|
+
}
|
|
6414
|
+
_getStat(filepath) {
|
|
6415
|
+
return new Promise((resolve, reject) => {
|
|
6416
|
+
this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
|
6417
|
+
return error === null ? resolve(stats) : reject(error);
|
|
6418
|
+
});
|
|
6419
|
+
});
|
|
6420
|
+
}
|
|
6421
|
+
}
|
|
6362
6422
|
stream$1.default = ReaderStream;
|
|
6363
6423
|
|
|
6364
|
-
Object.defineProperty(async$6, "__esModule", { value: true });
|
|
6365
|
-
const fsWalk$1 = out$3;
|
|
6366
|
-
const reader_1$1 = reader;
|
|
6367
|
-
const stream_1$2 = stream$1;
|
|
6368
|
-
class ReaderAsync extends reader_1$1.default {
|
|
6369
|
-
constructor() {
|
|
6370
|
-
super(...arguments);
|
|
6371
|
-
this._walkAsync = fsWalk$1.walk;
|
|
6372
|
-
this._readerStream = new stream_1$2.default(this._settings);
|
|
6373
|
-
}
|
|
6374
|
-
dynamic(root, options) {
|
|
6375
|
-
return new Promise((resolve, reject) => {
|
|
6376
|
-
this._walkAsync(root, options, (error, entries) => {
|
|
6377
|
-
if (error === null) {
|
|
6378
|
-
resolve(entries);
|
|
6379
|
-
}
|
|
6380
|
-
else {
|
|
6381
|
-
reject(error);
|
|
6382
|
-
}
|
|
6383
|
-
});
|
|
6384
|
-
});
|
|
6385
|
-
}
|
|
6386
|
-
async static(patterns, options) {
|
|
6387
|
-
const entries = [];
|
|
6388
|
-
const stream = this._readerStream.static(patterns, options);
|
|
6389
|
-
// After #235, replace it with an asynchronous iterator.
|
|
6390
|
-
return new Promise((resolve, reject) => {
|
|
6391
|
-
stream.once('error', reject);
|
|
6392
|
-
stream.on('data', (entry) => entries.push(entry));
|
|
6393
|
-
stream.once('end', () => resolve(entries));
|
|
6394
|
-
});
|
|
6395
|
-
}
|
|
6396
|
-
}
|
|
6424
|
+
Object.defineProperty(async$6, "__esModule", { value: true });
|
|
6425
|
+
const fsWalk$1 = out$3;
|
|
6426
|
+
const reader_1$1 = reader;
|
|
6427
|
+
const stream_1$2 = stream$1;
|
|
6428
|
+
class ReaderAsync extends reader_1$1.default {
|
|
6429
|
+
constructor() {
|
|
6430
|
+
super(...arguments);
|
|
6431
|
+
this._walkAsync = fsWalk$1.walk;
|
|
6432
|
+
this._readerStream = new stream_1$2.default(this._settings);
|
|
6433
|
+
}
|
|
6434
|
+
dynamic(root, options) {
|
|
6435
|
+
return new Promise((resolve, reject) => {
|
|
6436
|
+
this._walkAsync(root, options, (error, entries) => {
|
|
6437
|
+
if (error === null) {
|
|
6438
|
+
resolve(entries);
|
|
6439
|
+
}
|
|
6440
|
+
else {
|
|
6441
|
+
reject(error);
|
|
6442
|
+
}
|
|
6443
|
+
});
|
|
6444
|
+
});
|
|
6445
|
+
}
|
|
6446
|
+
async static(patterns, options) {
|
|
6447
|
+
const entries = [];
|
|
6448
|
+
const stream = this._readerStream.static(patterns, options);
|
|
6449
|
+
// After #235, replace it with an asynchronous iterator.
|
|
6450
|
+
return new Promise((resolve, reject) => {
|
|
6451
|
+
stream.once('error', reject);
|
|
6452
|
+
stream.on('data', (entry) => entries.push(entry));
|
|
6453
|
+
stream.once('end', () => resolve(entries));
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
}
|
|
6397
6457
|
async$6.default = ReaderAsync;
|
|
6398
6458
|
|
|
6399
6459
|
var provider = {};
|
|
@@ -6404,568 +6464,594 @@ var partial = {};
|
|
|
6404
6464
|
|
|
6405
6465
|
var matcher = {};
|
|
6406
6466
|
|
|
6407
|
-
Object.defineProperty(matcher, "__esModule", { value: true });
|
|
6408
|
-
const utils$5 = utils$k;
|
|
6409
|
-
class Matcher {
|
|
6410
|
-
constructor(_patterns, _settings, _micromatchOptions) {
|
|
6411
|
-
this._patterns = _patterns;
|
|
6412
|
-
this._settings = _settings;
|
|
6413
|
-
this._micromatchOptions = _micromatchOptions;
|
|
6414
|
-
this._storage = [];
|
|
6415
|
-
this._fillStorage();
|
|
6416
|
-
}
|
|
6417
|
-
_fillStorage() {
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
}
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
}
|
|
6451
|
-
_splitSegmentsIntoSections(segments) {
|
|
6452
|
-
return utils$5.array.splitWhen(segments, (segment) => segment.dynamic && utils$5.pattern.hasGlobStar(segment.pattern));
|
|
6453
|
-
}
|
|
6454
|
-
}
|
|
6467
|
+
Object.defineProperty(matcher, "__esModule", { value: true });
|
|
6468
|
+
const utils$5 = utils$k;
|
|
6469
|
+
class Matcher {
|
|
6470
|
+
constructor(_patterns, _settings, _micromatchOptions) {
|
|
6471
|
+
this._patterns = _patterns;
|
|
6472
|
+
this._settings = _settings;
|
|
6473
|
+
this._micromatchOptions = _micromatchOptions;
|
|
6474
|
+
this._storage = [];
|
|
6475
|
+
this._fillStorage();
|
|
6476
|
+
}
|
|
6477
|
+
_fillStorage() {
|
|
6478
|
+
for (const pattern of this._patterns) {
|
|
6479
|
+
const segments = this._getPatternSegments(pattern);
|
|
6480
|
+
const sections = this._splitSegmentsIntoSections(segments);
|
|
6481
|
+
this._storage.push({
|
|
6482
|
+
complete: sections.length <= 1,
|
|
6483
|
+
pattern,
|
|
6484
|
+
segments,
|
|
6485
|
+
sections
|
|
6486
|
+
});
|
|
6487
|
+
}
|
|
6488
|
+
}
|
|
6489
|
+
_getPatternSegments(pattern) {
|
|
6490
|
+
const parts = utils$5.pattern.getPatternParts(pattern, this._micromatchOptions);
|
|
6491
|
+
return parts.map((part) => {
|
|
6492
|
+
const dynamic = utils$5.pattern.isDynamicPattern(part, this._settings);
|
|
6493
|
+
if (!dynamic) {
|
|
6494
|
+
return {
|
|
6495
|
+
dynamic: false,
|
|
6496
|
+
pattern: part
|
|
6497
|
+
};
|
|
6498
|
+
}
|
|
6499
|
+
return {
|
|
6500
|
+
dynamic: true,
|
|
6501
|
+
pattern: part,
|
|
6502
|
+
patternRe: utils$5.pattern.makeRe(part, this._micromatchOptions)
|
|
6503
|
+
};
|
|
6504
|
+
});
|
|
6505
|
+
}
|
|
6506
|
+
_splitSegmentsIntoSections(segments) {
|
|
6507
|
+
return utils$5.array.splitWhen(segments, (segment) => segment.dynamic && utils$5.pattern.hasGlobStar(segment.pattern));
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6455
6510
|
matcher.default = Matcher;
|
|
6456
6511
|
|
|
6457
|
-
Object.defineProperty(partial, "__esModule", { value: true });
|
|
6458
|
-
const matcher_1 = matcher;
|
|
6459
|
-
class PartialMatcher extends matcher_1.default {
|
|
6460
|
-
match(filepath) {
|
|
6461
|
-
const parts = filepath.split('/');
|
|
6462
|
-
const levels = parts.length;
|
|
6463
|
-
const patterns = this._storage.filter((info) => !info.complete || info.segments.length > levels);
|
|
6464
|
-
for (const pattern of patterns) {
|
|
6465
|
-
const section = pattern.sections[0];
|
|
6466
|
-
/**
|
|
6467
|
-
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
|
6468
|
-
* but only if the level has reached the end of the first group.
|
|
6469
|
-
*
|
|
6470
|
-
* fixtures/{a,b}/**
|
|
6471
|
-
* ^ true/false ^ always true
|
|
6472
|
-
*/
|
|
6473
|
-
if (!pattern.complete && levels > section.length) {
|
|
6474
|
-
return true;
|
|
6475
|
-
}
|
|
6476
|
-
const match = parts.every((part, index) => {
|
|
6477
|
-
const segment = pattern.segments[index];
|
|
6478
|
-
if (segment.dynamic && segment.patternRe.test(part)) {
|
|
6479
|
-
return true;
|
|
6480
|
-
}
|
|
6481
|
-
if (!segment.dynamic && segment.pattern === part) {
|
|
6482
|
-
return true;
|
|
6483
|
-
}
|
|
6484
|
-
return false;
|
|
6485
|
-
});
|
|
6486
|
-
if (match) {
|
|
6487
|
-
return true;
|
|
6488
|
-
}
|
|
6489
|
-
}
|
|
6490
|
-
return false;
|
|
6491
|
-
}
|
|
6492
|
-
}
|
|
6512
|
+
Object.defineProperty(partial, "__esModule", { value: true });
|
|
6513
|
+
const matcher_1 = matcher;
|
|
6514
|
+
class PartialMatcher extends matcher_1.default {
|
|
6515
|
+
match(filepath) {
|
|
6516
|
+
const parts = filepath.split('/');
|
|
6517
|
+
const levels = parts.length;
|
|
6518
|
+
const patterns = this._storage.filter((info) => !info.complete || info.segments.length > levels);
|
|
6519
|
+
for (const pattern of patterns) {
|
|
6520
|
+
const section = pattern.sections[0];
|
|
6521
|
+
/**
|
|
6522
|
+
* In this case, the pattern has a globstar and we must read all directories unconditionally,
|
|
6523
|
+
* but only if the level has reached the end of the first group.
|
|
6524
|
+
*
|
|
6525
|
+
* fixtures/{a,b}/**
|
|
6526
|
+
* ^ true/false ^ always true
|
|
6527
|
+
*/
|
|
6528
|
+
if (!pattern.complete && levels > section.length) {
|
|
6529
|
+
return true;
|
|
6530
|
+
}
|
|
6531
|
+
const match = parts.every((part, index) => {
|
|
6532
|
+
const segment = pattern.segments[index];
|
|
6533
|
+
if (segment.dynamic && segment.patternRe.test(part)) {
|
|
6534
|
+
return true;
|
|
6535
|
+
}
|
|
6536
|
+
if (!segment.dynamic && segment.pattern === part) {
|
|
6537
|
+
return true;
|
|
6538
|
+
}
|
|
6539
|
+
return false;
|
|
6540
|
+
});
|
|
6541
|
+
if (match) {
|
|
6542
|
+
return true;
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
return false;
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6493
6548
|
partial.default = PartialMatcher;
|
|
6494
6549
|
|
|
6495
|
-
Object.defineProperty(deep, "__esModule", { value: true });
|
|
6496
|
-
const utils$4 = utils$k;
|
|
6497
|
-
const partial_1 = partial;
|
|
6498
|
-
class DeepFilter {
|
|
6499
|
-
constructor(_settings, _micromatchOptions) {
|
|
6500
|
-
this._settings = _settings;
|
|
6501
|
-
this._micromatchOptions = _micromatchOptions;
|
|
6502
|
-
}
|
|
6503
|
-
getFilter(basePath, positive, negative) {
|
|
6504
|
-
const matcher = this._getMatcher(positive);
|
|
6505
|
-
const negativeRe = this._getNegativePatternsRe(negative);
|
|
6506
|
-
return (entry) => this._filter(basePath, entry, matcher, negativeRe);
|
|
6507
|
-
}
|
|
6508
|
-
_getMatcher(patterns) {
|
|
6509
|
-
return new partial_1.default(patterns, this._settings, this._micromatchOptions);
|
|
6510
|
-
}
|
|
6511
|
-
_getNegativePatternsRe(patterns) {
|
|
6512
|
-
const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
|
|
6513
|
-
return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
|
|
6514
|
-
}
|
|
6515
|
-
_filter(basePath, entry, matcher, negativeRe) {
|
|
6516
|
-
if (this._isSkippedByDeep(basePath, entry.path)) {
|
|
6517
|
-
return false;
|
|
6518
|
-
}
|
|
6519
|
-
if (this._isSkippedSymbolicLink(entry)) {
|
|
6520
|
-
return false;
|
|
6521
|
-
}
|
|
6522
|
-
const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
|
|
6523
|
-
if (this._isSkippedByPositivePatterns(filepath, matcher)) {
|
|
6524
|
-
return false;
|
|
6525
|
-
}
|
|
6526
|
-
return this._isSkippedByNegativePatterns(filepath, negativeRe);
|
|
6527
|
-
}
|
|
6528
|
-
_isSkippedByDeep(basePath, entryPath) {
|
|
6529
|
-
/**
|
|
6530
|
-
* Avoid unnecessary depth calculations when it doesn't matter.
|
|
6531
|
-
*/
|
|
6532
|
-
if (this._settings.deep === Infinity) {
|
|
6533
|
-
return false;
|
|
6534
|
-
}
|
|
6535
|
-
return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
|
|
6536
|
-
}
|
|
6537
|
-
_getEntryLevel(basePath, entryPath) {
|
|
6538
|
-
const entryPathDepth = entryPath.split('/').length;
|
|
6539
|
-
if (basePath === '') {
|
|
6540
|
-
return entryPathDepth;
|
|
6541
|
-
}
|
|
6542
|
-
const basePathDepth = basePath.split('/').length;
|
|
6543
|
-
return entryPathDepth - basePathDepth;
|
|
6544
|
-
}
|
|
6545
|
-
_isSkippedSymbolicLink(entry) {
|
|
6546
|
-
return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
|
|
6547
|
-
}
|
|
6548
|
-
_isSkippedByPositivePatterns(entryPath, matcher) {
|
|
6549
|
-
return !this._settings.baseNameMatch && !matcher.match(entryPath);
|
|
6550
|
-
}
|
|
6551
|
-
_isSkippedByNegativePatterns(entryPath, patternsRe) {
|
|
6552
|
-
return !utils$4.pattern.matchAny(entryPath, patternsRe);
|
|
6553
|
-
}
|
|
6554
|
-
}
|
|
6550
|
+
Object.defineProperty(deep, "__esModule", { value: true });
|
|
6551
|
+
const utils$4 = utils$k;
|
|
6552
|
+
const partial_1 = partial;
|
|
6553
|
+
class DeepFilter {
|
|
6554
|
+
constructor(_settings, _micromatchOptions) {
|
|
6555
|
+
this._settings = _settings;
|
|
6556
|
+
this._micromatchOptions = _micromatchOptions;
|
|
6557
|
+
}
|
|
6558
|
+
getFilter(basePath, positive, negative) {
|
|
6559
|
+
const matcher = this._getMatcher(positive);
|
|
6560
|
+
const negativeRe = this._getNegativePatternsRe(negative);
|
|
6561
|
+
return (entry) => this._filter(basePath, entry, matcher, negativeRe);
|
|
6562
|
+
}
|
|
6563
|
+
_getMatcher(patterns) {
|
|
6564
|
+
return new partial_1.default(patterns, this._settings, this._micromatchOptions);
|
|
6565
|
+
}
|
|
6566
|
+
_getNegativePatternsRe(patterns) {
|
|
6567
|
+
const affectDepthOfReadingPatterns = patterns.filter(utils$4.pattern.isAffectDepthOfReadingPattern);
|
|
6568
|
+
return utils$4.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions);
|
|
6569
|
+
}
|
|
6570
|
+
_filter(basePath, entry, matcher, negativeRe) {
|
|
6571
|
+
if (this._isSkippedByDeep(basePath, entry.path)) {
|
|
6572
|
+
return false;
|
|
6573
|
+
}
|
|
6574
|
+
if (this._isSkippedSymbolicLink(entry)) {
|
|
6575
|
+
return false;
|
|
6576
|
+
}
|
|
6577
|
+
const filepath = utils$4.path.removeLeadingDotSegment(entry.path);
|
|
6578
|
+
if (this._isSkippedByPositivePatterns(filepath, matcher)) {
|
|
6579
|
+
return false;
|
|
6580
|
+
}
|
|
6581
|
+
return this._isSkippedByNegativePatterns(filepath, negativeRe);
|
|
6582
|
+
}
|
|
6583
|
+
_isSkippedByDeep(basePath, entryPath) {
|
|
6584
|
+
/**
|
|
6585
|
+
* Avoid unnecessary depth calculations when it doesn't matter.
|
|
6586
|
+
*/
|
|
6587
|
+
if (this._settings.deep === Infinity) {
|
|
6588
|
+
return false;
|
|
6589
|
+
}
|
|
6590
|
+
return this._getEntryLevel(basePath, entryPath) >= this._settings.deep;
|
|
6591
|
+
}
|
|
6592
|
+
_getEntryLevel(basePath, entryPath) {
|
|
6593
|
+
const entryPathDepth = entryPath.split('/').length;
|
|
6594
|
+
if (basePath === '') {
|
|
6595
|
+
return entryPathDepth;
|
|
6596
|
+
}
|
|
6597
|
+
const basePathDepth = basePath.split('/').length;
|
|
6598
|
+
return entryPathDepth - basePathDepth;
|
|
6599
|
+
}
|
|
6600
|
+
_isSkippedSymbolicLink(entry) {
|
|
6601
|
+
return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
|
|
6602
|
+
}
|
|
6603
|
+
_isSkippedByPositivePatterns(entryPath, matcher) {
|
|
6604
|
+
return !this._settings.baseNameMatch && !matcher.match(entryPath);
|
|
6605
|
+
}
|
|
6606
|
+
_isSkippedByNegativePatterns(entryPath, patternsRe) {
|
|
6607
|
+
return !utils$4.pattern.matchAny(entryPath, patternsRe);
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6555
6610
|
deep.default = DeepFilter;
|
|
6556
6611
|
|
|
6557
6612
|
var entry$1 = {};
|
|
6558
6613
|
|
|
6559
|
-
Object.defineProperty(entry$1, "__esModule", { value: true });
|
|
6560
|
-
const utils$3 = utils$k;
|
|
6561
|
-
class EntryFilter {
|
|
6562
|
-
constructor(_settings, _micromatchOptions) {
|
|
6563
|
-
this._settings = _settings;
|
|
6564
|
-
this._micromatchOptions = _micromatchOptions;
|
|
6565
|
-
this.index = new Map();
|
|
6566
|
-
}
|
|
6567
|
-
getFilter(positive, negative) {
|
|
6568
|
-
const positiveRe = utils$3.pattern.convertPatternsToRe(positive, this._micromatchOptions);
|
|
6569
|
-
const negativeRe = utils$3.pattern.convertPatternsToRe(negative, this._micromatchOptions);
|
|
6570
|
-
return (entry) => this._filter(entry, positiveRe, negativeRe);
|
|
6571
|
-
}
|
|
6572
|
-
_filter(entry, positiveRe, negativeRe) {
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
const isDirectory = entry.dirent.isDirectory();
|
|
6584
|
-
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(
|
|
6585
|
-
if (this._settings.unique && isMatched) {
|
|
6586
|
-
this._createIndexRecord(
|
|
6587
|
-
}
|
|
6588
|
-
return isMatched;
|
|
6589
|
-
}
|
|
6590
|
-
_isDuplicateEntry(
|
|
6591
|
-
return this.index.has(
|
|
6592
|
-
}
|
|
6593
|
-
_createIndexRecord(
|
|
6594
|
-
this.index.set(
|
|
6595
|
-
}
|
|
6596
|
-
_onlyFileFilter(entry) {
|
|
6597
|
-
return this._settings.onlyFiles && !entry.dirent.isFile();
|
|
6598
|
-
}
|
|
6599
|
-
_onlyDirectoryFilter(entry) {
|
|
6600
|
-
return this._settings.onlyDirectories && !entry.dirent.isDirectory();
|
|
6601
|
-
}
|
|
6602
|
-
_isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
|
|
6603
|
-
if (!this._settings.absolute) {
|
|
6604
|
-
return false;
|
|
6605
|
-
}
|
|
6606
|
-
const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
|
|
6607
|
-
return utils$3.pattern.matchAny(fullpath, patternsRe);
|
|
6608
|
-
}
|
|
6609
|
-
_isMatchToPatterns(
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
//
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
}
|
|
6614
|
+
Object.defineProperty(entry$1, "__esModule", { value: true });
|
|
6615
|
+
const utils$3 = utils$k;
|
|
6616
|
+
class EntryFilter {
|
|
6617
|
+
constructor(_settings, _micromatchOptions) {
|
|
6618
|
+
this._settings = _settings;
|
|
6619
|
+
this._micromatchOptions = _micromatchOptions;
|
|
6620
|
+
this.index = new Map();
|
|
6621
|
+
}
|
|
6622
|
+
getFilter(positive, negative) {
|
|
6623
|
+
const positiveRe = utils$3.pattern.convertPatternsToRe(positive, this._micromatchOptions);
|
|
6624
|
+
const negativeRe = utils$3.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true }));
|
|
6625
|
+
return (entry) => this._filter(entry, positiveRe, negativeRe);
|
|
6626
|
+
}
|
|
6627
|
+
_filter(entry, positiveRe, negativeRe) {
|
|
6628
|
+
const filepath = utils$3.path.removeLeadingDotSegment(entry.path);
|
|
6629
|
+
if (this._settings.unique && this._isDuplicateEntry(filepath)) {
|
|
6630
|
+
return false;
|
|
6631
|
+
}
|
|
6632
|
+
if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
|
|
6633
|
+
return false;
|
|
6634
|
+
}
|
|
6635
|
+
if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) {
|
|
6636
|
+
return false;
|
|
6637
|
+
}
|
|
6638
|
+
const isDirectory = entry.dirent.isDirectory();
|
|
6639
|
+
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
|
|
6640
|
+
if (this._settings.unique && isMatched) {
|
|
6641
|
+
this._createIndexRecord(filepath);
|
|
6642
|
+
}
|
|
6643
|
+
return isMatched;
|
|
6644
|
+
}
|
|
6645
|
+
_isDuplicateEntry(filepath) {
|
|
6646
|
+
return this.index.has(filepath);
|
|
6647
|
+
}
|
|
6648
|
+
_createIndexRecord(filepath) {
|
|
6649
|
+
this.index.set(filepath, undefined);
|
|
6650
|
+
}
|
|
6651
|
+
_onlyFileFilter(entry) {
|
|
6652
|
+
return this._settings.onlyFiles && !entry.dirent.isFile();
|
|
6653
|
+
}
|
|
6654
|
+
_onlyDirectoryFilter(entry) {
|
|
6655
|
+
return this._settings.onlyDirectories && !entry.dirent.isDirectory();
|
|
6656
|
+
}
|
|
6657
|
+
_isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
|
|
6658
|
+
if (!this._settings.absolute) {
|
|
6659
|
+
return false;
|
|
6660
|
+
}
|
|
6661
|
+
const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
|
|
6662
|
+
return utils$3.pattern.matchAny(fullpath, patternsRe);
|
|
6663
|
+
}
|
|
6664
|
+
_isMatchToPatterns(filepath, patternsRe, isDirectory) {
|
|
6665
|
+
// Trying to match files and directories by patterns.
|
|
6666
|
+
const isMatched = utils$3.pattern.matchAny(filepath, patternsRe);
|
|
6667
|
+
// A pattern with a trailling slash can be used for directory matching.
|
|
6668
|
+
// To apply such pattern, we need to add a tralling slash to the path.
|
|
6669
|
+
if (!isMatched && isDirectory) {
|
|
6670
|
+
return utils$3.pattern.matchAny(filepath + '/', patternsRe);
|
|
6671
|
+
}
|
|
6672
|
+
return isMatched;
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6621
6675
|
entry$1.default = EntryFilter;
|
|
6622
6676
|
|
|
6623
6677
|
var error = {};
|
|
6624
6678
|
|
|
6625
|
-
Object.defineProperty(error, "__esModule", { value: true });
|
|
6626
|
-
const utils$2 = utils$k;
|
|
6627
|
-
class ErrorFilter {
|
|
6628
|
-
constructor(_settings) {
|
|
6629
|
-
this._settings = _settings;
|
|
6630
|
-
}
|
|
6631
|
-
getFilter() {
|
|
6632
|
-
return (error) => this._isNonFatalError(error);
|
|
6633
|
-
}
|
|
6634
|
-
_isNonFatalError(error) {
|
|
6635
|
-
return utils$2.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
|
|
6636
|
-
}
|
|
6637
|
-
}
|
|
6679
|
+
Object.defineProperty(error, "__esModule", { value: true });
|
|
6680
|
+
const utils$2 = utils$k;
|
|
6681
|
+
class ErrorFilter {
|
|
6682
|
+
constructor(_settings) {
|
|
6683
|
+
this._settings = _settings;
|
|
6684
|
+
}
|
|
6685
|
+
getFilter() {
|
|
6686
|
+
return (error) => this._isNonFatalError(error);
|
|
6687
|
+
}
|
|
6688
|
+
_isNonFatalError(error) {
|
|
6689
|
+
return utils$2.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6638
6692
|
error.default = ErrorFilter;
|
|
6639
6693
|
|
|
6640
6694
|
var entry = {};
|
|
6641
6695
|
|
|
6642
|
-
Object.defineProperty(entry, "__esModule", { value: true });
|
|
6643
|
-
const utils$1 = utils$k;
|
|
6644
|
-
class EntryTransformer {
|
|
6645
|
-
constructor(_settings) {
|
|
6646
|
-
this._settings = _settings;
|
|
6647
|
-
}
|
|
6648
|
-
getTransformer() {
|
|
6649
|
-
return (entry) => this._transform(entry);
|
|
6650
|
-
}
|
|
6651
|
-
_transform(entry) {
|
|
6652
|
-
let filepath = entry.path;
|
|
6653
|
-
if (this._settings.absolute) {
|
|
6654
|
-
filepath = utils$1.path.makeAbsolute(this._settings.cwd, filepath);
|
|
6655
|
-
filepath = utils$1.path.unixify(filepath);
|
|
6656
|
-
}
|
|
6657
|
-
if (this._settings.markDirectories && entry.dirent.isDirectory()) {
|
|
6658
|
-
filepath += '/';
|
|
6659
|
-
}
|
|
6660
|
-
if (!this._settings.objectMode) {
|
|
6661
|
-
return filepath;
|
|
6662
|
-
}
|
|
6663
|
-
return Object.assign(Object.assign({}, entry), { path: filepath });
|
|
6664
|
-
}
|
|
6665
|
-
}
|
|
6696
|
+
Object.defineProperty(entry, "__esModule", { value: true });
|
|
6697
|
+
const utils$1 = utils$k;
|
|
6698
|
+
class EntryTransformer {
|
|
6699
|
+
constructor(_settings) {
|
|
6700
|
+
this._settings = _settings;
|
|
6701
|
+
}
|
|
6702
|
+
getTransformer() {
|
|
6703
|
+
return (entry) => this._transform(entry);
|
|
6704
|
+
}
|
|
6705
|
+
_transform(entry) {
|
|
6706
|
+
let filepath = entry.path;
|
|
6707
|
+
if (this._settings.absolute) {
|
|
6708
|
+
filepath = utils$1.path.makeAbsolute(this._settings.cwd, filepath);
|
|
6709
|
+
filepath = utils$1.path.unixify(filepath);
|
|
6710
|
+
}
|
|
6711
|
+
if (this._settings.markDirectories && entry.dirent.isDirectory()) {
|
|
6712
|
+
filepath += '/';
|
|
6713
|
+
}
|
|
6714
|
+
if (!this._settings.objectMode) {
|
|
6715
|
+
return filepath;
|
|
6716
|
+
}
|
|
6717
|
+
return Object.assign(Object.assign({}, entry), { path: filepath });
|
|
6718
|
+
}
|
|
6719
|
+
}
|
|
6666
6720
|
entry.default = EntryTransformer;
|
|
6667
6721
|
|
|
6668
|
-
Object.defineProperty(provider, "__esModule", { value: true });
|
|
6669
|
-
const path = f$1;
|
|
6670
|
-
const deep_1 = deep;
|
|
6671
|
-
const entry_1 = entry$1;
|
|
6672
|
-
const error_1 = error;
|
|
6673
|
-
const entry_2 = entry;
|
|
6674
|
-
class Provider {
|
|
6675
|
-
constructor(_settings) {
|
|
6676
|
-
this._settings = _settings;
|
|
6677
|
-
this.errorFilter = new error_1.default(this._settings);
|
|
6678
|
-
this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
|
|
6679
|
-
this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
|
|
6680
|
-
this.entryTransformer = new entry_2.default(this._settings);
|
|
6681
|
-
}
|
|
6682
|
-
_getRootDirectory(task) {
|
|
6683
|
-
return path.resolve(this._settings.cwd, task.base);
|
|
6684
|
-
}
|
|
6685
|
-
_getReaderOptions(task) {
|
|
6686
|
-
const basePath = task.base === '.' ? '' : task.base;
|
|
6687
|
-
return {
|
|
6688
|
-
basePath,
|
|
6689
|
-
pathSegmentSeparator: '/',
|
|
6690
|
-
concurrency: this._settings.concurrency,
|
|
6691
|
-
deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
|
|
6692
|
-
entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
|
|
6693
|
-
errorFilter: this.errorFilter.getFilter(),
|
|
6694
|
-
followSymbolicLinks: this._settings.followSymbolicLinks,
|
|
6695
|
-
fs: this._settings.fs,
|
|
6696
|
-
stats: this._settings.stats,
|
|
6697
|
-
throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
|
|
6698
|
-
transform: this.entryTransformer.getTransformer()
|
|
6699
|
-
};
|
|
6700
|
-
}
|
|
6701
|
-
_getMicromatchOptions() {
|
|
6702
|
-
return {
|
|
6703
|
-
dot: this._settings.dot,
|
|
6704
|
-
matchBase: this._settings.baseNameMatch,
|
|
6705
|
-
nobrace: !this._settings.braceExpansion,
|
|
6706
|
-
nocase: !this._settings.caseSensitiveMatch,
|
|
6707
|
-
noext: !this._settings.extglob,
|
|
6708
|
-
noglobstar: !this._settings.globstar,
|
|
6709
|
-
posix: true,
|
|
6710
|
-
strictSlashes: false
|
|
6711
|
-
};
|
|
6712
|
-
}
|
|
6713
|
-
}
|
|
6722
|
+
Object.defineProperty(provider, "__esModule", { value: true });
|
|
6723
|
+
const path = f$1;
|
|
6724
|
+
const deep_1 = deep;
|
|
6725
|
+
const entry_1 = entry$1;
|
|
6726
|
+
const error_1 = error;
|
|
6727
|
+
const entry_2 = entry;
|
|
6728
|
+
class Provider {
|
|
6729
|
+
constructor(_settings) {
|
|
6730
|
+
this._settings = _settings;
|
|
6731
|
+
this.errorFilter = new error_1.default(this._settings);
|
|
6732
|
+
this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions());
|
|
6733
|
+
this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions());
|
|
6734
|
+
this.entryTransformer = new entry_2.default(this._settings);
|
|
6735
|
+
}
|
|
6736
|
+
_getRootDirectory(task) {
|
|
6737
|
+
return path.resolve(this._settings.cwd, task.base);
|
|
6738
|
+
}
|
|
6739
|
+
_getReaderOptions(task) {
|
|
6740
|
+
const basePath = task.base === '.' ? '' : task.base;
|
|
6741
|
+
return {
|
|
6742
|
+
basePath,
|
|
6743
|
+
pathSegmentSeparator: '/',
|
|
6744
|
+
concurrency: this._settings.concurrency,
|
|
6745
|
+
deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
|
|
6746
|
+
entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
|
|
6747
|
+
errorFilter: this.errorFilter.getFilter(),
|
|
6748
|
+
followSymbolicLinks: this._settings.followSymbolicLinks,
|
|
6749
|
+
fs: this._settings.fs,
|
|
6750
|
+
stats: this._settings.stats,
|
|
6751
|
+
throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
|
|
6752
|
+
transform: this.entryTransformer.getTransformer()
|
|
6753
|
+
};
|
|
6754
|
+
}
|
|
6755
|
+
_getMicromatchOptions() {
|
|
6756
|
+
return {
|
|
6757
|
+
dot: this._settings.dot,
|
|
6758
|
+
matchBase: this._settings.baseNameMatch,
|
|
6759
|
+
nobrace: !this._settings.braceExpansion,
|
|
6760
|
+
nocase: !this._settings.caseSensitiveMatch,
|
|
6761
|
+
noext: !this._settings.extglob,
|
|
6762
|
+
noglobstar: !this._settings.globstar,
|
|
6763
|
+
posix: true,
|
|
6764
|
+
strictSlashes: false
|
|
6765
|
+
};
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6714
6768
|
provider.default = Provider;
|
|
6715
6769
|
|
|
6716
|
-
Object.defineProperty(async$7, "__esModule", { value: true });
|
|
6717
|
-
const async_1$1 = async$6;
|
|
6718
|
-
const provider_1$2 = provider;
|
|
6719
|
-
class ProviderAsync extends provider_1$2.default {
|
|
6720
|
-
constructor() {
|
|
6721
|
-
super(...arguments);
|
|
6722
|
-
this._reader = new async_1$1.default(this._settings);
|
|
6723
|
-
}
|
|
6724
|
-
async read(task) {
|
|
6725
|
-
const root = this._getRootDirectory(task);
|
|
6726
|
-
const options = this._getReaderOptions(task);
|
|
6727
|
-
const entries = await this.api(root, task, options);
|
|
6728
|
-
return entries.map((entry) => options.transform(entry));
|
|
6729
|
-
}
|
|
6730
|
-
api(root, task, options) {
|
|
6731
|
-
if (task.dynamic) {
|
|
6732
|
-
return this._reader.dynamic(root, options);
|
|
6733
|
-
}
|
|
6734
|
-
return this._reader.static(task.patterns, options);
|
|
6735
|
-
}
|
|
6736
|
-
}
|
|
6770
|
+
Object.defineProperty(async$7, "__esModule", { value: true });
|
|
6771
|
+
const async_1$1 = async$6;
|
|
6772
|
+
const provider_1$2 = provider;
|
|
6773
|
+
class ProviderAsync extends provider_1$2.default {
|
|
6774
|
+
constructor() {
|
|
6775
|
+
super(...arguments);
|
|
6776
|
+
this._reader = new async_1$1.default(this._settings);
|
|
6777
|
+
}
|
|
6778
|
+
async read(task) {
|
|
6779
|
+
const root = this._getRootDirectory(task);
|
|
6780
|
+
const options = this._getReaderOptions(task);
|
|
6781
|
+
const entries = await this.api(root, task, options);
|
|
6782
|
+
return entries.map((entry) => options.transform(entry));
|
|
6783
|
+
}
|
|
6784
|
+
api(root, task, options) {
|
|
6785
|
+
if (task.dynamic) {
|
|
6786
|
+
return this._reader.dynamic(root, options);
|
|
6787
|
+
}
|
|
6788
|
+
return this._reader.static(task.patterns, options);
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6737
6791
|
async$7.default = ProviderAsync;
|
|
6738
6792
|
|
|
6739
6793
|
var stream = {};
|
|
6740
6794
|
|
|
6741
|
-
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6742
|
-
const stream_1$1 = require$$0$1;
|
|
6743
|
-
const stream_2 = stream$1;
|
|
6744
|
-
const provider_1$1 = provider;
|
|
6745
|
-
class ProviderStream extends provider_1$1.default {
|
|
6746
|
-
constructor() {
|
|
6747
|
-
super(...arguments);
|
|
6748
|
-
this._reader = new stream_2.default(this._settings);
|
|
6749
|
-
}
|
|
6750
|
-
read(task) {
|
|
6751
|
-
const root = this._getRootDirectory(task);
|
|
6752
|
-
const options = this._getReaderOptions(task);
|
|
6753
|
-
const source = this.api(root, task, options);
|
|
6754
|
-
const destination = new stream_1$1.Readable({ objectMode: true, read: () => { } });
|
|
6755
|
-
source
|
|
6756
|
-
.once('error', (error) => destination.emit('error', error))
|
|
6757
|
-
.on('data', (entry) => destination.emit('data', options.transform(entry)))
|
|
6758
|
-
.once('end', () => destination.emit('end'));
|
|
6759
|
-
destination
|
|
6760
|
-
.once('close', () => source.destroy());
|
|
6761
|
-
return destination;
|
|
6762
|
-
}
|
|
6763
|
-
api(root, task, options) {
|
|
6764
|
-
if (task.dynamic) {
|
|
6765
|
-
return this._reader.dynamic(root, options);
|
|
6766
|
-
}
|
|
6767
|
-
return this._reader.static(task.patterns, options);
|
|
6768
|
-
}
|
|
6769
|
-
}
|
|
6795
|
+
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6796
|
+
const stream_1$1 = require$$0$1;
|
|
6797
|
+
const stream_2 = stream$1;
|
|
6798
|
+
const provider_1$1 = provider;
|
|
6799
|
+
class ProviderStream extends provider_1$1.default {
|
|
6800
|
+
constructor() {
|
|
6801
|
+
super(...arguments);
|
|
6802
|
+
this._reader = new stream_2.default(this._settings);
|
|
6803
|
+
}
|
|
6804
|
+
read(task) {
|
|
6805
|
+
const root = this._getRootDirectory(task);
|
|
6806
|
+
const options = this._getReaderOptions(task);
|
|
6807
|
+
const source = this.api(root, task, options);
|
|
6808
|
+
const destination = new stream_1$1.Readable({ objectMode: true, read: () => { } });
|
|
6809
|
+
source
|
|
6810
|
+
.once('error', (error) => destination.emit('error', error))
|
|
6811
|
+
.on('data', (entry) => destination.emit('data', options.transform(entry)))
|
|
6812
|
+
.once('end', () => destination.emit('end'));
|
|
6813
|
+
destination
|
|
6814
|
+
.once('close', () => source.destroy());
|
|
6815
|
+
return destination;
|
|
6816
|
+
}
|
|
6817
|
+
api(root, task, options) {
|
|
6818
|
+
if (task.dynamic) {
|
|
6819
|
+
return this._reader.dynamic(root, options);
|
|
6820
|
+
}
|
|
6821
|
+
return this._reader.static(task.patterns, options);
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6770
6824
|
stream.default = ProviderStream;
|
|
6771
6825
|
|
|
6772
6826
|
var sync$1 = {};
|
|
6773
6827
|
|
|
6774
6828
|
var sync = {};
|
|
6775
6829
|
|
|
6776
|
-
Object.defineProperty(sync, "__esModule", { value: true });
|
|
6777
|
-
const fsStat = out$1;
|
|
6778
|
-
const fsWalk = out$3;
|
|
6779
|
-
const reader_1 = reader;
|
|
6780
|
-
class ReaderSync extends reader_1.default {
|
|
6781
|
-
constructor() {
|
|
6782
|
-
super(...arguments);
|
|
6783
|
-
this._walkSync = fsWalk.walkSync;
|
|
6784
|
-
this._statSync = fsStat.statSync;
|
|
6785
|
-
}
|
|
6786
|
-
dynamic(root, options) {
|
|
6787
|
-
return this._walkSync(root, options);
|
|
6788
|
-
}
|
|
6789
|
-
static(patterns, options) {
|
|
6790
|
-
const entries = [];
|
|
6791
|
-
for (const pattern of patterns) {
|
|
6792
|
-
const filepath = this._getFullEntryPath(pattern);
|
|
6793
|
-
const entry = this._getEntry(filepath, pattern, options);
|
|
6794
|
-
if (entry === null || !options.entryFilter(entry)) {
|
|
6795
|
-
continue;
|
|
6796
|
-
}
|
|
6797
|
-
entries.push(entry);
|
|
6798
|
-
}
|
|
6799
|
-
return entries;
|
|
6800
|
-
}
|
|
6801
|
-
_getEntry(filepath, pattern, options) {
|
|
6802
|
-
try {
|
|
6803
|
-
const stats = this._getStat(filepath);
|
|
6804
|
-
return this._makeEntry(stats, pattern);
|
|
6805
|
-
}
|
|
6806
|
-
catch (error) {
|
|
6807
|
-
if (options.errorFilter(error)) {
|
|
6808
|
-
return null;
|
|
6809
|
-
}
|
|
6810
|
-
throw error;
|
|
6811
|
-
}
|
|
6812
|
-
}
|
|
6813
|
-
_getStat(filepath) {
|
|
6814
|
-
return this._statSync(filepath, this._fsStatSettings);
|
|
6815
|
-
}
|
|
6816
|
-
}
|
|
6830
|
+
Object.defineProperty(sync, "__esModule", { value: true });
|
|
6831
|
+
const fsStat = out$1;
|
|
6832
|
+
const fsWalk = out$3;
|
|
6833
|
+
const reader_1 = reader;
|
|
6834
|
+
class ReaderSync extends reader_1.default {
|
|
6835
|
+
constructor() {
|
|
6836
|
+
super(...arguments);
|
|
6837
|
+
this._walkSync = fsWalk.walkSync;
|
|
6838
|
+
this._statSync = fsStat.statSync;
|
|
6839
|
+
}
|
|
6840
|
+
dynamic(root, options) {
|
|
6841
|
+
return this._walkSync(root, options);
|
|
6842
|
+
}
|
|
6843
|
+
static(patterns, options) {
|
|
6844
|
+
const entries = [];
|
|
6845
|
+
for (const pattern of patterns) {
|
|
6846
|
+
const filepath = this._getFullEntryPath(pattern);
|
|
6847
|
+
const entry = this._getEntry(filepath, pattern, options);
|
|
6848
|
+
if (entry === null || !options.entryFilter(entry)) {
|
|
6849
|
+
continue;
|
|
6850
|
+
}
|
|
6851
|
+
entries.push(entry);
|
|
6852
|
+
}
|
|
6853
|
+
return entries;
|
|
6854
|
+
}
|
|
6855
|
+
_getEntry(filepath, pattern, options) {
|
|
6856
|
+
try {
|
|
6857
|
+
const stats = this._getStat(filepath);
|
|
6858
|
+
return this._makeEntry(stats, pattern);
|
|
6859
|
+
}
|
|
6860
|
+
catch (error) {
|
|
6861
|
+
if (options.errorFilter(error)) {
|
|
6862
|
+
return null;
|
|
6863
|
+
}
|
|
6864
|
+
throw error;
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6867
|
+
_getStat(filepath) {
|
|
6868
|
+
return this._statSync(filepath, this._fsStatSettings);
|
|
6869
|
+
}
|
|
6870
|
+
}
|
|
6817
6871
|
sync.default = ReaderSync;
|
|
6818
6872
|
|
|
6819
|
-
Object.defineProperty(sync$1, "__esModule", { value: true });
|
|
6820
|
-
const sync_1$1 = sync;
|
|
6821
|
-
const provider_1 = provider;
|
|
6822
|
-
class ProviderSync extends provider_1.default {
|
|
6823
|
-
constructor() {
|
|
6824
|
-
super(...arguments);
|
|
6825
|
-
this._reader = new sync_1$1.default(this._settings);
|
|
6826
|
-
}
|
|
6827
|
-
read(task) {
|
|
6828
|
-
const root = this._getRootDirectory(task);
|
|
6829
|
-
const options = this._getReaderOptions(task);
|
|
6830
|
-
const entries = this.api(root, task, options);
|
|
6831
|
-
return entries.map(options.transform);
|
|
6832
|
-
}
|
|
6833
|
-
api(root, task, options) {
|
|
6834
|
-
if (task.dynamic) {
|
|
6835
|
-
return this._reader.dynamic(root, options);
|
|
6836
|
-
}
|
|
6837
|
-
return this._reader.static(task.patterns, options);
|
|
6838
|
-
}
|
|
6839
|
-
}
|
|
6873
|
+
Object.defineProperty(sync$1, "__esModule", { value: true });
|
|
6874
|
+
const sync_1$1 = sync;
|
|
6875
|
+
const provider_1 = provider;
|
|
6876
|
+
class ProviderSync extends provider_1.default {
|
|
6877
|
+
constructor() {
|
|
6878
|
+
super(...arguments);
|
|
6879
|
+
this._reader = new sync_1$1.default(this._settings);
|
|
6880
|
+
}
|
|
6881
|
+
read(task) {
|
|
6882
|
+
const root = this._getRootDirectory(task);
|
|
6883
|
+
const options = this._getReaderOptions(task);
|
|
6884
|
+
const entries = this.api(root, task, options);
|
|
6885
|
+
return entries.map(options.transform);
|
|
6886
|
+
}
|
|
6887
|
+
api(root, task, options) {
|
|
6888
|
+
if (task.dynamic) {
|
|
6889
|
+
return this._reader.dynamic(root, options);
|
|
6890
|
+
}
|
|
6891
|
+
return this._reader.static(task.patterns, options);
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6840
6894
|
sync$1.default = ProviderSync;
|
|
6841
6895
|
|
|
6842
6896
|
var settings = {};
|
|
6843
6897
|
|
|
6844
6898
|
(function (exports) {
|
|
6845
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6846
|
-
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
6847
|
-
const fs = $;
|
|
6848
|
-
const os = require$$0;
|
|
6849
|
-
/**
|
|
6850
|
-
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
6851
|
-
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
6852
|
-
*/
|
|
6853
|
-
const CPU_COUNT = Math.max(os.cpus().length, 1);
|
|
6854
|
-
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
6855
|
-
lstat: fs.lstat,
|
|
6856
|
-
lstatSync: fs.lstatSync,
|
|
6857
|
-
stat: fs.stat,
|
|
6858
|
-
statSync: fs.statSync,
|
|
6859
|
-
readdir: fs.readdir,
|
|
6860
|
-
readdirSync: fs.readdirSync
|
|
6861
|
-
};
|
|
6862
|
-
class Settings {
|
|
6863
|
-
constructor(_options = {}) {
|
|
6864
|
-
this._options = _options;
|
|
6865
|
-
this.absolute = this._getValue(this._options.absolute, false);
|
|
6866
|
-
this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
|
|
6867
|
-
this.braceExpansion = this._getValue(this._options.braceExpansion, true);
|
|
6868
|
-
this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
|
|
6869
|
-
this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
|
|
6870
|
-
this.cwd = this._getValue(this._options.cwd, process.cwd());
|
|
6871
|
-
this.deep = this._getValue(this._options.deep, Infinity);
|
|
6872
|
-
this.dot = this._getValue(this._options.dot, false);
|
|
6873
|
-
this.extglob = this._getValue(this._options.extglob, true);
|
|
6874
|
-
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
|
|
6875
|
-
this.fs = this._getFileSystemMethods(this._options.fs);
|
|
6876
|
-
this.globstar = this._getValue(this._options.globstar, true);
|
|
6877
|
-
this.ignore = this._getValue(this._options.ignore, []);
|
|
6878
|
-
this.markDirectories = this._getValue(this._options.markDirectories, false);
|
|
6879
|
-
this.objectMode = this._getValue(this._options.objectMode, false);
|
|
6880
|
-
this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
|
|
6881
|
-
this.onlyFiles = this._getValue(this._options.onlyFiles, true);
|
|
6882
|
-
this.stats = this._getValue(this._options.stats, false);
|
|
6883
|
-
this.suppressErrors = this._getValue(this._options.suppressErrors, false);
|
|
6884
|
-
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
|
|
6885
|
-
this.unique = this._getValue(this._options.unique, true);
|
|
6886
|
-
if (this.onlyDirectories) {
|
|
6887
|
-
this.onlyFiles = false;
|
|
6888
|
-
}
|
|
6889
|
-
if (this.stats) {
|
|
6890
|
-
this.objectMode = true;
|
|
6891
|
-
}
|
|
6892
|
-
}
|
|
6893
|
-
_getValue(option, value) {
|
|
6894
|
-
return option === undefined ? value : option;
|
|
6895
|
-
}
|
|
6896
|
-
_getFileSystemMethods(methods = {}) {
|
|
6897
|
-
return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
|
|
6898
|
-
}
|
|
6899
|
-
}
|
|
6899
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6900
|
+
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
6901
|
+
const fs = $;
|
|
6902
|
+
const os = require$$0;
|
|
6903
|
+
/**
|
|
6904
|
+
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
6905
|
+
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
6906
|
+
*/
|
|
6907
|
+
const CPU_COUNT = Math.max(os.cpus().length, 1);
|
|
6908
|
+
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
6909
|
+
lstat: fs.lstat,
|
|
6910
|
+
lstatSync: fs.lstatSync,
|
|
6911
|
+
stat: fs.stat,
|
|
6912
|
+
statSync: fs.statSync,
|
|
6913
|
+
readdir: fs.readdir,
|
|
6914
|
+
readdirSync: fs.readdirSync
|
|
6915
|
+
};
|
|
6916
|
+
class Settings {
|
|
6917
|
+
constructor(_options = {}) {
|
|
6918
|
+
this._options = _options;
|
|
6919
|
+
this.absolute = this._getValue(this._options.absolute, false);
|
|
6920
|
+
this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
|
|
6921
|
+
this.braceExpansion = this._getValue(this._options.braceExpansion, true);
|
|
6922
|
+
this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
|
|
6923
|
+
this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
|
|
6924
|
+
this.cwd = this._getValue(this._options.cwd, process.cwd());
|
|
6925
|
+
this.deep = this._getValue(this._options.deep, Infinity);
|
|
6926
|
+
this.dot = this._getValue(this._options.dot, false);
|
|
6927
|
+
this.extglob = this._getValue(this._options.extglob, true);
|
|
6928
|
+
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
|
|
6929
|
+
this.fs = this._getFileSystemMethods(this._options.fs);
|
|
6930
|
+
this.globstar = this._getValue(this._options.globstar, true);
|
|
6931
|
+
this.ignore = this._getValue(this._options.ignore, []);
|
|
6932
|
+
this.markDirectories = this._getValue(this._options.markDirectories, false);
|
|
6933
|
+
this.objectMode = this._getValue(this._options.objectMode, false);
|
|
6934
|
+
this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
|
|
6935
|
+
this.onlyFiles = this._getValue(this._options.onlyFiles, true);
|
|
6936
|
+
this.stats = this._getValue(this._options.stats, false);
|
|
6937
|
+
this.suppressErrors = this._getValue(this._options.suppressErrors, false);
|
|
6938
|
+
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
|
|
6939
|
+
this.unique = this._getValue(this._options.unique, true);
|
|
6940
|
+
if (this.onlyDirectories) {
|
|
6941
|
+
this.onlyFiles = false;
|
|
6942
|
+
}
|
|
6943
|
+
if (this.stats) {
|
|
6944
|
+
this.objectMode = true;
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
_getValue(option, value) {
|
|
6948
|
+
return option === undefined ? value : option;
|
|
6949
|
+
}
|
|
6950
|
+
_getFileSystemMethods(methods = {}) {
|
|
6951
|
+
return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
|
|
6952
|
+
}
|
|
6953
|
+
}
|
|
6900
6954
|
exports.default = Settings;
|
|
6901
6955
|
} (settings));
|
|
6902
6956
|
|
|
6903
|
-
const taskManager = tasks;
|
|
6904
|
-
const
|
|
6905
|
-
const
|
|
6906
|
-
const
|
|
6907
|
-
const
|
|
6908
|
-
const
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
const
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
//
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
function
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6957
|
+
const taskManager = tasks;
|
|
6958
|
+
const async_1 = async$7;
|
|
6959
|
+
const stream_1 = stream;
|
|
6960
|
+
const sync_1 = sync$1;
|
|
6961
|
+
const settings_1 = settings;
|
|
6962
|
+
const utils = utils$k;
|
|
6963
|
+
async function FastGlob(source, options) {
|
|
6964
|
+
assertPatternsInput(source);
|
|
6965
|
+
const works = getWorks(source, async_1.default, options);
|
|
6966
|
+
const result = await Promise.all(works);
|
|
6967
|
+
return utils.array.flatten(result);
|
|
6968
|
+
}
|
|
6969
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/60
|
|
6970
|
+
// eslint-disable-next-line no-redeclare
|
|
6971
|
+
(function (FastGlob) {
|
|
6972
|
+
FastGlob.glob = FastGlob;
|
|
6973
|
+
FastGlob.globSync = sync;
|
|
6974
|
+
FastGlob.globStream = stream;
|
|
6975
|
+
FastGlob.async = FastGlob;
|
|
6976
|
+
function sync(source, options) {
|
|
6977
|
+
assertPatternsInput(source);
|
|
6978
|
+
const works = getWorks(source, sync_1.default, options);
|
|
6979
|
+
return utils.array.flatten(works);
|
|
6980
|
+
}
|
|
6981
|
+
FastGlob.sync = sync;
|
|
6982
|
+
function stream(source, options) {
|
|
6983
|
+
assertPatternsInput(source);
|
|
6984
|
+
const works = getWorks(source, stream_1.default, options);
|
|
6985
|
+
/**
|
|
6986
|
+
* The stream returned by the provider cannot work with an asynchronous iterator.
|
|
6987
|
+
* To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
|
|
6988
|
+
* This affects performance (+25%). I don't see best solution right now.
|
|
6989
|
+
*/
|
|
6990
|
+
return utils.stream.merge(works);
|
|
6991
|
+
}
|
|
6992
|
+
FastGlob.stream = stream;
|
|
6993
|
+
function generateTasks(source, options) {
|
|
6994
|
+
assertPatternsInput(source);
|
|
6995
|
+
const patterns = [].concat(source);
|
|
6996
|
+
const settings = new settings_1.default(options);
|
|
6997
|
+
return taskManager.generate(patterns, settings);
|
|
6998
|
+
}
|
|
6999
|
+
FastGlob.generateTasks = generateTasks;
|
|
7000
|
+
function isDynamicPattern(source, options) {
|
|
7001
|
+
assertPatternsInput(source);
|
|
7002
|
+
const settings = new settings_1.default(options);
|
|
7003
|
+
return utils.pattern.isDynamicPattern(source, settings);
|
|
7004
|
+
}
|
|
7005
|
+
FastGlob.isDynamicPattern = isDynamicPattern;
|
|
7006
|
+
function escapePath(source) {
|
|
7007
|
+
assertPatternsInput(source);
|
|
7008
|
+
return utils.path.escape(source);
|
|
7009
|
+
}
|
|
7010
|
+
FastGlob.escapePath = escapePath;
|
|
7011
|
+
function convertPathToPattern(source) {
|
|
7012
|
+
assertPatternsInput(source);
|
|
7013
|
+
return utils.path.convertPathToPattern(source);
|
|
7014
|
+
}
|
|
7015
|
+
FastGlob.convertPathToPattern = convertPathToPattern;
|
|
7016
|
+
(function (posix) {
|
|
7017
|
+
function escapePath(source) {
|
|
7018
|
+
assertPatternsInput(source);
|
|
7019
|
+
return utils.path.escapePosixPath(source);
|
|
7020
|
+
}
|
|
7021
|
+
posix.escapePath = escapePath;
|
|
7022
|
+
function convertPathToPattern(source) {
|
|
7023
|
+
assertPatternsInput(source);
|
|
7024
|
+
return utils.path.convertPosixPathToPattern(source);
|
|
7025
|
+
}
|
|
7026
|
+
posix.convertPathToPattern = convertPathToPattern;
|
|
7027
|
+
})(FastGlob.posix || (FastGlob.posix = {}));
|
|
7028
|
+
(function (win32) {
|
|
7029
|
+
function escapePath(source) {
|
|
7030
|
+
assertPatternsInput(source);
|
|
7031
|
+
return utils.path.escapeWindowsPath(source);
|
|
7032
|
+
}
|
|
7033
|
+
win32.escapePath = escapePath;
|
|
7034
|
+
function convertPathToPattern(source) {
|
|
7035
|
+
assertPatternsInput(source);
|
|
7036
|
+
return utils.path.convertWindowsPathToPattern(source);
|
|
7037
|
+
}
|
|
7038
|
+
win32.convertPathToPattern = convertPathToPattern;
|
|
7039
|
+
})(FastGlob.win32 || (FastGlob.win32 = {}));
|
|
7040
|
+
})(FastGlob || (FastGlob = {}));
|
|
7041
|
+
function getWorks(source, _Provider, options) {
|
|
7042
|
+
const patterns = [].concat(source);
|
|
7043
|
+
const settings = new settings_1.default(options);
|
|
7044
|
+
const tasks = taskManager.generate(patterns, settings);
|
|
7045
|
+
const provider = new _Provider(settings);
|
|
7046
|
+
return tasks.map(provider.read, provider);
|
|
7047
|
+
}
|
|
7048
|
+
function assertPatternsInput(input) {
|
|
7049
|
+
const source = [].concat(input);
|
|
7050
|
+
const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
|
|
7051
|
+
if (!isValidSource) {
|
|
7052
|
+
throw new TypeError('Patterns must be a string (non empty) or an array of strings');
|
|
7053
|
+
}
|
|
7054
|
+
}
|
|
6969
7055
|
var out = FastGlob;
|
|
6970
7056
|
|
|
6971
7057
|
var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
|
|
@@ -6976,6 +7062,13 @@ const envsOrder = [
|
|
|
6976
7062
|
"happy-dom",
|
|
6977
7063
|
"edge-runtime"
|
|
6978
7064
|
];
|
|
7065
|
+
function getTransformMode(patterns, filename) {
|
|
7066
|
+
if (patterns.web && mm.isMatch(filename, patterns.web))
|
|
7067
|
+
return "web";
|
|
7068
|
+
if (patterns.ssr && mm.isMatch(filename, patterns.ssr))
|
|
7069
|
+
return "ssr";
|
|
7070
|
+
return void 0;
|
|
7071
|
+
}
|
|
6979
7072
|
async function groupFilesByEnv(files) {
|
|
6980
7073
|
const filesWithEnv = await Promise.all(files.map(async ([project, file]) => {
|
|
6981
7074
|
var _a, _b;
|
|
@@ -6990,12 +7083,14 @@ async function groupFilesByEnv(files) {
|
|
|
6990
7083
|
}
|
|
6991
7084
|
}
|
|
6992
7085
|
env || (env = project.config.environment || "node");
|
|
7086
|
+
const transformMode = getTransformMode(project.config.testTransformMode, file);
|
|
6993
7087
|
const envOptions = JSON.parse(((_b = code.match(/@(?:vitest|jest)-environment-options\s+?(.+)/)) == null ? void 0 : _b[1]) || "null");
|
|
6994
7088
|
return {
|
|
6995
7089
|
file,
|
|
6996
7090
|
project,
|
|
6997
7091
|
environment: {
|
|
6998
7092
|
name: env,
|
|
7093
|
+
transformMode,
|
|
6999
7094
|
options: envOptions ? { [env]: envOptions } : null
|
|
7000
7095
|
}
|
|
7001
7096
|
};
|
|
@@ -7007,7 +7102,7 @@ function createMethodsRPC(project) {
|
|
|
7007
7102
|
const ctx = project.ctx;
|
|
7008
7103
|
return {
|
|
7009
7104
|
async onWorkerExit(error, code) {
|
|
7010
|
-
await ctx.logger.printError(error,
|
|
7105
|
+
await ctx.logger.printError(error, { type: "Unexpected Exit" });
|
|
7011
7106
|
process.exit(code || 1);
|
|
7012
7107
|
},
|
|
7013
7108
|
snapshotSaved(snapshot) {
|
|
@@ -7025,12 +7120,10 @@ function createMethodsRPC(project) {
|
|
|
7025
7120
|
const r = await project.vitenode.transformRequest(id);
|
|
7026
7121
|
return r == null ? void 0 : r.map;
|
|
7027
7122
|
},
|
|
7028
|
-
fetch(id,
|
|
7029
|
-
const transformMode = getEnvironmentTransformMode(project.config, environment);
|
|
7123
|
+
fetch(id, transformMode) {
|
|
7030
7124
|
return project.vitenode.fetchModule(id, transformMode);
|
|
7031
7125
|
},
|
|
7032
|
-
resolveId(id, importer,
|
|
7033
|
-
const transformMode = getEnvironmentTransformMode(project.config, environment);
|
|
7126
|
+
resolveId(id, importer, transformMode) {
|
|
7034
7127
|
return project.vitenode.resolveId(id, importer, transformMode);
|
|
7035
7128
|
},
|
|
7036
7129
|
onPathsCollected(paths) {
|
|
@@ -7068,7 +7161,7 @@ function createMethodsRPC(project) {
|
|
|
7068
7161
|
};
|
|
7069
7162
|
}
|
|
7070
7163
|
|
|
7071
|
-
const childPath = fileURLToPath(pathToFileURL(resolve
|
|
7164
|
+
const childPath = fileURLToPath(pathToFileURL(resolve(distDir, "./child.js")).href);
|
|
7072
7165
|
function setupChildProcessChannel(project, fork2) {
|
|
7073
7166
|
const rpc = createBirpc(
|
|
7074
7167
|
createMethodsRPC(project),
|
|
@@ -7115,6 +7208,8 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7115
7208
|
const child = fork(childPath, [], {
|
|
7116
7209
|
execArgv,
|
|
7117
7210
|
env
|
|
7211
|
+
// TODO: investigate
|
|
7212
|
+
// serialization: 'advanced',
|
|
7118
7213
|
});
|
|
7119
7214
|
children.add(child);
|
|
7120
7215
|
setupChildProcessChannel(project, child);
|
|
@@ -7145,7 +7240,7 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7145
7240
|
const files = filesByEnv[env2];
|
|
7146
7241
|
if (!(files == null ? void 0 : files.length))
|
|
7147
7242
|
continue;
|
|
7148
|
-
const filesByOptions = groupBy(files, ({ project, environment }) => project.getName() + JSON.stringify(environment.options));
|
|
7243
|
+
const filesByOptions = groupBy(files, ({ project, environment }) => project.getName() + JSON.stringify(environment.options) + environment.transformMode);
|
|
7149
7244
|
for (const option in filesByOptions) {
|
|
7150
7245
|
const files2 = filesByOptions[option];
|
|
7151
7246
|
if (files2 == null ? void 0 : files2.length) {
|
|
@@ -7167,8 +7262,8 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7167
7262
|
};
|
|
7168
7263
|
}
|
|
7169
7264
|
|
|
7170
|
-
const workerPath = pathToFileURL(resolve
|
|
7171
|
-
function createWorkerChannel(project) {
|
|
7265
|
+
const workerPath$1 = pathToFileURL(resolve(distDir, "./worker.js")).href;
|
|
7266
|
+
function createWorkerChannel$1(project) {
|
|
7172
7267
|
const channel = new MessageChannel();
|
|
7173
7268
|
const port = channel.port2;
|
|
7174
7269
|
const workerPort = channel.port1;
|
|
@@ -7192,7 +7287,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7192
7287
|
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7193
7288
|
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7194
7289
|
const options = {
|
|
7195
|
-
filename: workerPath,
|
|
7290
|
+
filename: workerPath$1,
|
|
7196
7291
|
// TODO: investigate further
|
|
7197
7292
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7198
7293
|
useAtomics: ctx.config.useAtomics ?? false,
|
|
@@ -7216,7 +7311,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7216
7311
|
let id = 0;
|
|
7217
7312
|
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
7218
7313
|
ctx.state.clearFiles(project, files);
|
|
7219
|
-
const { workerPort, port } = createWorkerChannel(project);
|
|
7314
|
+
const { workerPort, port } = createWorkerChannel$1(project);
|
|
7220
7315
|
const workerId = ++id;
|
|
7221
7316
|
const data = {
|
|
7222
7317
|
port: workerPort,
|
|
@@ -7266,8 +7361,18 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7266
7361
|
const multipleThreads = specs.filter(([project]) => !project.config.singleThread);
|
|
7267
7362
|
if (multipleThreads.length) {
|
|
7268
7363
|
const filesByEnv = await groupFilesByEnv(multipleThreads);
|
|
7269
|
-
const
|
|
7270
|
-
const results =
|
|
7364
|
+
const files = Object.values(filesByEnv).flat();
|
|
7365
|
+
const results = [];
|
|
7366
|
+
if (ctx.config.isolate) {
|
|
7367
|
+
results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7368
|
+
} else {
|
|
7369
|
+
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
7370
|
+
for (const group of Object.values(grouped)) {
|
|
7371
|
+
results.push(...await Promise.allSettled(group.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7372
|
+
await new Promise((resolve2) => pool.queueSize === 0 ? resolve2() : pool.once("drain", resolve2));
|
|
7373
|
+
await pool.recycleWorkers();
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7271
7376
|
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
7272
7377
|
if (errors.length > 0)
|
|
7273
7378
|
throw new AggregateErrorPonyfill(errors, "Errors occurred while running tests. For more information, see serialized error.");
|
|
@@ -7282,11 +7387,11 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7282
7387
|
if (!(files == null ? void 0 : files.length))
|
|
7283
7388
|
continue;
|
|
7284
7389
|
const filesByOptions = groupBy(files, ({ project, environment }) => project.getName() + JSON.stringify(environment.options));
|
|
7285
|
-
const
|
|
7390
|
+
for (const files2 of Object.values(filesByOptions)) {
|
|
7391
|
+
await pool.recycleWorkers();
|
|
7286
7392
|
const filenames = files2.map((f) => f.file);
|
|
7287
7393
|
await runFiles(files2[0].project, getConfig(files2[0].project), filenames, files2[0].environment, invalidates);
|
|
7288
|
-
}
|
|
7289
|
-
await Promise.all(promises);
|
|
7394
|
+
}
|
|
7290
7395
|
}
|
|
7291
7396
|
}
|
|
7292
7397
|
};
|
|
@@ -7345,45 +7450,158 @@ function createBrowserPool(ctx) {
|
|
|
7345
7450
|
await provider.openPage(url.toString());
|
|
7346
7451
|
await waitForTest(provider, path);
|
|
7347
7452
|
}
|
|
7348
|
-
} else {
|
|
7349
|
-
const url = new URL("/", origin);
|
|
7350
|
-
url.searchParams.set("id", "no-isolate");
|
|
7351
|
-
paths.forEach((path) => url.searchParams.append("path", path));
|
|
7352
|
-
await provider.openPage(url.toString());
|
|
7353
|
-
await waitForTest(provider, "no-isolate");
|
|
7354
|
-
}
|
|
7355
|
-
};
|
|
7356
|
-
const runWorkspaceTests = async (specs) => {
|
|
7357
|
-
const groupedFiles = /* @__PURE__ */ new Map();
|
|
7358
|
-
for (const [project, file] of specs) {
|
|
7359
|
-
const files = groupedFiles.get(project) || [];
|
|
7360
|
-
files.push(file);
|
|
7361
|
-
groupedFiles.set(project, files);
|
|
7453
|
+
} else {
|
|
7454
|
+
const url = new URL("/", origin);
|
|
7455
|
+
url.searchParams.set("id", "no-isolate");
|
|
7456
|
+
paths.forEach((path) => url.searchParams.append("path", path));
|
|
7457
|
+
await provider.openPage(url.toString());
|
|
7458
|
+
await waitForTest(provider, "no-isolate");
|
|
7459
|
+
}
|
|
7460
|
+
};
|
|
7461
|
+
const runWorkspaceTests = async (specs) => {
|
|
7462
|
+
const groupedFiles = /* @__PURE__ */ new Map();
|
|
7463
|
+
for (const [project, file] of specs) {
|
|
7464
|
+
const files = groupedFiles.get(project) || [];
|
|
7465
|
+
files.push(file);
|
|
7466
|
+
groupedFiles.set(project, files);
|
|
7467
|
+
}
|
|
7468
|
+
for (const [project, files] of groupedFiles.entries())
|
|
7469
|
+
await runTests(project, files);
|
|
7470
|
+
};
|
|
7471
|
+
return {
|
|
7472
|
+
async close() {
|
|
7473
|
+
ctx.state.browserTestPromises.clear();
|
|
7474
|
+
await Promise.all([...providers].map((provider) => provider.close()));
|
|
7475
|
+
providers.clear();
|
|
7476
|
+
},
|
|
7477
|
+
runTests: runWorkspaceTests
|
|
7478
|
+
};
|
|
7479
|
+
}
|
|
7480
|
+
|
|
7481
|
+
const workerPath = pathToFileURL(resolve(distDir, "./vm.js")).href;
|
|
7482
|
+
const suppressLoaderWarningsPath$1 = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7483
|
+
function createWorkerChannel(project) {
|
|
7484
|
+
const channel = new MessageChannel();
|
|
7485
|
+
const port = channel.port2;
|
|
7486
|
+
const workerPort = channel.port1;
|
|
7487
|
+
const rpc = createBirpc(
|
|
7488
|
+
createMethodsRPC(project),
|
|
7489
|
+
{
|
|
7490
|
+
eventNames: ["onCancel"],
|
|
7491
|
+
post(v) {
|
|
7492
|
+
port.postMessage(v);
|
|
7493
|
+
},
|
|
7494
|
+
on(fn) {
|
|
7495
|
+
port.on("message", fn);
|
|
7496
|
+
}
|
|
7497
|
+
}
|
|
7498
|
+
);
|
|
7499
|
+
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
7500
|
+
return { workerPort, port };
|
|
7501
|
+
}
|
|
7502
|
+
function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
7503
|
+
const threadsCount = ctx.config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
|
|
7504
|
+
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7505
|
+
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7506
|
+
const options = {
|
|
7507
|
+
filename: workerPath,
|
|
7508
|
+
// TODO: investigate further
|
|
7509
|
+
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7510
|
+
useAtomics: ctx.config.useAtomics ?? false,
|
|
7511
|
+
maxThreads,
|
|
7512
|
+
minThreads,
|
|
7513
|
+
env,
|
|
7514
|
+
execArgv: [
|
|
7515
|
+
"--experimental-import-meta-resolve",
|
|
7516
|
+
"--experimental-vm-modules",
|
|
7517
|
+
"--require",
|
|
7518
|
+
suppressLoaderWarningsPath$1,
|
|
7519
|
+
...execArgv
|
|
7520
|
+
],
|
|
7521
|
+
terminateTimeout: ctx.config.teardownTimeout
|
|
7522
|
+
};
|
|
7523
|
+
if (ctx.config.singleThread) {
|
|
7524
|
+
options.concurrentTasksPerWorker = 1;
|
|
7525
|
+
options.maxThreads = 1;
|
|
7526
|
+
options.minThreads = 1;
|
|
7527
|
+
}
|
|
7528
|
+
const pool = new Tinypool(options);
|
|
7529
|
+
const runWithFiles = (name) => {
|
|
7530
|
+
let id = 0;
|
|
7531
|
+
async function runFiles(project, config, files, environment, invalidates = []) {
|
|
7532
|
+
ctx.state.clearFiles(project, files);
|
|
7533
|
+
const { workerPort, port } = createWorkerChannel(project);
|
|
7534
|
+
const workerId = ++id;
|
|
7535
|
+
const data = {
|
|
7536
|
+
port: workerPort,
|
|
7537
|
+
config,
|
|
7538
|
+
files,
|
|
7539
|
+
invalidates,
|
|
7540
|
+
environment,
|
|
7541
|
+
workerId
|
|
7542
|
+
};
|
|
7543
|
+
try {
|
|
7544
|
+
await pool.run(data, { transferList: [workerPort], name });
|
|
7545
|
+
} catch (error) {
|
|
7546
|
+
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
7547
|
+
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
7548
|
+
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
7549
|
+
ctx.state.cancelFiles(files, ctx.config.root);
|
|
7550
|
+
else
|
|
7551
|
+
throw error;
|
|
7552
|
+
} finally {
|
|
7553
|
+
port.close();
|
|
7554
|
+
workerPort.close();
|
|
7555
|
+
}
|
|
7362
7556
|
}
|
|
7363
|
-
|
|
7364
|
-
|
|
7557
|
+
const Sequencer = ctx.config.sequence.sequencer;
|
|
7558
|
+
const sequencer = new Sequencer(ctx);
|
|
7559
|
+
return async (specs, invalidates) => {
|
|
7560
|
+
const configs = /* @__PURE__ */ new Map();
|
|
7561
|
+
const getConfig = (project) => {
|
|
7562
|
+
if (configs.has(project))
|
|
7563
|
+
return configs.get(project);
|
|
7564
|
+
const config = project.getSerializableConfig();
|
|
7565
|
+
configs.set(project, config);
|
|
7566
|
+
return config;
|
|
7567
|
+
};
|
|
7568
|
+
const { shard } = ctx.config;
|
|
7569
|
+
if (shard)
|
|
7570
|
+
specs = await sequencer.shard(specs);
|
|
7571
|
+
specs = await sequencer.sort(specs);
|
|
7572
|
+
const filesByEnv = await groupFilesByEnv(specs);
|
|
7573
|
+
const promises = Object.values(filesByEnv).flat();
|
|
7574
|
+
const results = await Promise.allSettled(promises.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates)));
|
|
7575
|
+
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
7576
|
+
if (errors.length > 0)
|
|
7577
|
+
throw new AggregateErrorPonyfill(errors, "Errors occurred while running tests. For more information, see serialized error.");
|
|
7578
|
+
};
|
|
7365
7579
|
};
|
|
7366
7580
|
return {
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7581
|
+
runTests: runWithFiles("run"),
|
|
7582
|
+
close: async () => {
|
|
7583
|
+
var _a;
|
|
7584
|
+
const nodeVersion = Number((_a = process.version.match(/v(\d+)\.(\d+)/)) == null ? void 0 : _a[0].slice(1));
|
|
7585
|
+
if (nodeVersion >= 16.17)
|
|
7586
|
+
await pool.destroy();
|
|
7587
|
+
}
|
|
7373
7588
|
};
|
|
7374
7589
|
}
|
|
7375
7590
|
|
|
7376
|
-
const loaderPath = pathToFileURL(resolve
|
|
7377
|
-
const suppressLoaderWarningsPath = resolve
|
|
7591
|
+
const loaderPath = pathToFileURL(resolve(distDir, "./loader.js")).href;
|
|
7592
|
+
const suppressLoaderWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7378
7593
|
function createPool(ctx) {
|
|
7379
7594
|
const pools = {
|
|
7380
7595
|
child_process: null,
|
|
7381
7596
|
threads: null,
|
|
7382
|
-
browser: null
|
|
7597
|
+
browser: null,
|
|
7598
|
+
experimentalVmThreads: null
|
|
7383
7599
|
};
|
|
7384
7600
|
function getDefaultPoolName(project) {
|
|
7385
7601
|
if (project.config.browser.enabled)
|
|
7386
7602
|
return "browser";
|
|
7603
|
+
if (project.config.experimentalVmThreads)
|
|
7604
|
+
return "experimentalVmThreads";
|
|
7387
7605
|
if (project.config.threads)
|
|
7388
7606
|
return "threads";
|
|
7389
7607
|
return "child_process";
|
|
@@ -7409,7 +7627,8 @@ function createPool(ctx) {
|
|
|
7409
7627
|
"--require",
|
|
7410
7628
|
suppressLoaderWarningsPath,
|
|
7411
7629
|
"--experimental-loader",
|
|
7412
|
-
loaderPath
|
|
7630
|
+
loaderPath,
|
|
7631
|
+
...conditions
|
|
7413
7632
|
] : [
|
|
7414
7633
|
...execArgv,
|
|
7415
7634
|
...conditions
|
|
@@ -7426,10 +7645,13 @@ function createPool(ctx) {
|
|
|
7426
7645
|
const filesByPool = {
|
|
7427
7646
|
child_process: [],
|
|
7428
7647
|
threads: [],
|
|
7429
|
-
browser: []
|
|
7648
|
+
browser: [],
|
|
7649
|
+
experimentalVmThreads: []
|
|
7430
7650
|
};
|
|
7431
7651
|
for (const spec of files) {
|
|
7432
7652
|
const pool = getPoolName(spec);
|
|
7653
|
+
if (!(pool in filesByPool))
|
|
7654
|
+
throw new Error(`Unknown pool name "${pool}" for ${spec[1]}. Available pools: ${Object.keys(filesByPool).join(", ")}`);
|
|
7433
7655
|
filesByPool[pool].push(spec);
|
|
7434
7656
|
}
|
|
7435
7657
|
await Promise.all(Object.entries(filesByPool).map(([pool, files2]) => {
|
|
@@ -7439,6 +7661,10 @@ function createPool(ctx) {
|
|
|
7439
7661
|
pools.browser ?? (pools.browser = createBrowserPool(ctx));
|
|
7440
7662
|
return pools.browser.runTests(files2, invalidate);
|
|
7441
7663
|
}
|
|
7664
|
+
if (pool === "experimentalVmThreads") {
|
|
7665
|
+
pools.experimentalVmThreads ?? (pools.experimentalVmThreads = createVmThreadsPool(ctx, options));
|
|
7666
|
+
return pools.experimentalVmThreads.runTests(files2, invalidate);
|
|
7667
|
+
}
|
|
7442
7668
|
if (pool === "threads") {
|
|
7443
7669
|
pools.threads ?? (pools.threads = createThreadsPool(ctx, options));
|
|
7444
7670
|
return pools.threads.runTests(files2, invalidate);
|
|
@@ -7950,8 +8176,13 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
7950
8176
|
for (const task of tasks) {
|
|
7951
8177
|
(_b = (_a2 = task.result) == null ? void 0 : _a2.errors) == null ? void 0 : _b.forEach((error) => {
|
|
7952
8178
|
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
7953
|
-
var _a3;
|
|
7954
|
-
|
|
8179
|
+
var _a3, _b2, _c2, _d;
|
|
8180
|
+
const hasStr = ((_a3 = i[0]) == null ? void 0 : _a3.stackStr) === error.stackStr;
|
|
8181
|
+
if (!hasStr)
|
|
8182
|
+
return false;
|
|
8183
|
+
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
8184
|
+
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName);
|
|
8185
|
+
return projectName === currentProjectName;
|
|
7955
8186
|
});
|
|
7956
8187
|
if (errorItem)
|
|
7957
8188
|
errorItem[1].push(task);
|
|
@@ -7968,7 +8199,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
7968
8199
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
7969
8200
|
this.ctx.logger.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
|
|
7970
8201
|
}
|
|
7971
|
-
|
|
8202
|
+
const project = this.ctx.getProjectByTaskId(tasks2[0].id);
|
|
8203
|
+
await this.ctx.logger.printError(error, { project });
|
|
7972
8204
|
errorDivider();
|
|
7973
8205
|
await Promise.resolve();
|
|
7974
8206
|
}
|
|
@@ -7976,7 +8208,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
7976
8208
|
registerUnhandledRejection() {
|
|
7977
8209
|
process.on("unhandledRejection", async (err) => {
|
|
7978
8210
|
process.exitCode = 1;
|
|
7979
|
-
await this.ctx.logger.printError(err, true, "Unhandled Rejection");
|
|
8211
|
+
await this.ctx.logger.printError(err, { fullStack: true, type: "Unhandled Rejection" });
|
|
7980
8212
|
this.ctx.logger.error("\n\n");
|
|
7981
8213
|
process.exit(1);
|
|
7982
8214
|
});
|
|
@@ -9328,7 +9560,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
9328
9560
|
async writeReport(report) {
|
|
9329
9561
|
const outputFile = getOutputFile(this.ctx.config, "json");
|
|
9330
9562
|
if (outputFile) {
|
|
9331
|
-
const reportFile = resolve
|
|
9563
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
9332
9564
|
const outputDirectory = dirname(reportFile);
|
|
9333
9565
|
if (!existsSync(outputDirectory))
|
|
9334
9566
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -9343,7 +9575,10 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
9343
9575
|
const error = (_b = (_a = test.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0];
|
|
9344
9576
|
if (!error)
|
|
9345
9577
|
return;
|
|
9346
|
-
const
|
|
9578
|
+
const project = this.ctx.getProjectByTaskId(test.id);
|
|
9579
|
+
const stack = parseErrorStacktrace(error, {
|
|
9580
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
9581
|
+
});
|
|
9347
9582
|
const frame = stack[0];
|
|
9348
9583
|
if (!frame)
|
|
9349
9584
|
return;
|
|
@@ -9442,10 +9677,13 @@ class TapReporter {
|
|
|
9442
9677
|
this.logger.log("}");
|
|
9443
9678
|
} else {
|
|
9444
9679
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment}`);
|
|
9680
|
+
const project = this.ctx.getProjectByTaskId(task.id);
|
|
9445
9681
|
if (((_b = task.result) == null ? void 0 : _b.state) === "fail" && task.result.errors) {
|
|
9446
9682
|
this.logger.indent();
|
|
9447
9683
|
task.result.errors.forEach((error) => {
|
|
9448
|
-
const stacks = parseErrorStacktrace(error
|
|
9684
|
+
const stacks = parseErrorStacktrace(error, {
|
|
9685
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
9686
|
+
});
|
|
9449
9687
|
const stack = stacks[0];
|
|
9450
9688
|
this.logger.log("---");
|
|
9451
9689
|
this.logger.log("error:");
|
|
@@ -9519,7 +9757,7 @@ class JUnitReporter {
|
|
|
9519
9757
|
this.ctx = ctx;
|
|
9520
9758
|
const outputFile = getOutputFile(this.ctx.config, "junit");
|
|
9521
9759
|
if (outputFile) {
|
|
9522
|
-
this.reportFile = resolve
|
|
9760
|
+
this.reportFile = resolve(this.ctx.config.root, outputFile);
|
|
9523
9761
|
const outputDirectory = dirname(this.reportFile);
|
|
9524
9762
|
if (!existsSync(outputDirectory))
|
|
9525
9763
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -9551,11 +9789,14 @@ class JUnitReporter {
|
|
|
9551
9789
|
this.logger.unindent();
|
|
9552
9790
|
await this.logger.log(`</${name}>`);
|
|
9553
9791
|
}
|
|
9554
|
-
async writeErrorDetails(error) {
|
|
9792
|
+
async writeErrorDetails(task, error) {
|
|
9555
9793
|
const errorName = error.name ?? error.nameStr ?? "Unknown Error";
|
|
9556
9794
|
const errorDetails = `${errorName}: ${error.message}`;
|
|
9557
9795
|
await this.baseLog(escapeXML(errorDetails));
|
|
9558
|
-
const
|
|
9796
|
+
const project = this.ctx.getProjectByTaskId(task.id);
|
|
9797
|
+
const stack = parseErrorStacktrace(error, {
|
|
9798
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
9799
|
+
});
|
|
9559
9800
|
for (const frame of stack) {
|
|
9560
9801
|
const path = relative(this.ctx.config.root, frame.file);
|
|
9561
9802
|
await this.baseLog(escapeXML(` ${F_POINTER} ${[frame.method, `${path}:${frame.line}:${frame.column}`].filter(Boolean).join(" ")}`));
|
|
@@ -9578,7 +9819,7 @@ class JUnitReporter {
|
|
|
9578
9819
|
async writeTasks(tasks, filename) {
|
|
9579
9820
|
for (const task of tasks) {
|
|
9580
9821
|
await this.writeElement("testcase", {
|
|
9581
|
-
classname: filename,
|
|
9822
|
+
classname: process.env.VITEST_JUNIT_CLASSNAME ?? filename,
|
|
9582
9823
|
name: task.name,
|
|
9583
9824
|
time: getDuration(task)
|
|
9584
9825
|
}, async () => {
|
|
@@ -9596,7 +9837,7 @@ class JUnitReporter {
|
|
|
9596
9837
|
}, async () => {
|
|
9597
9838
|
if (!error)
|
|
9598
9839
|
return;
|
|
9599
|
-
await this.writeErrorDetails(error);
|
|
9840
|
+
await this.writeErrorDetails(task, error);
|
|
9600
9841
|
});
|
|
9601
9842
|
}
|
|
9602
9843
|
}
|
|
@@ -9748,7 +9989,7 @@ class JsonReporter {
|
|
|
9748
9989
|
async writeReport(report) {
|
|
9749
9990
|
const outputFile = getOutputFile(this.ctx.config.benchmark, "json");
|
|
9750
9991
|
if (outputFile) {
|
|
9751
|
-
const reportFile = resolve
|
|
9992
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
9752
9993
|
const outputDirectory = dirname(reportFile);
|
|
9753
9994
|
if (!existsSync(outputDirectory))
|
|
9754
9995
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -10047,7 +10288,6 @@ function isAggregateError(err) {
|
|
|
10047
10288
|
class StateManager {
|
|
10048
10289
|
filesMap = /* @__PURE__ */ new Map();
|
|
10049
10290
|
pathsSet = /* @__PURE__ */ new Set();
|
|
10050
|
-
collectingPromise = void 0;
|
|
10051
10291
|
browserTestPromises = /* @__PURE__ */ new Map();
|
|
10052
10292
|
idMap = /* @__PURE__ */ new Map();
|
|
10053
10293
|
taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -10105,7 +10345,9 @@ class StateManager {
|
|
|
10105
10345
|
this.updateId(file);
|
|
10106
10346
|
});
|
|
10107
10347
|
}
|
|
10108
|
-
|
|
10348
|
+
// this file is reused by ws-client, and shoult not rely on heavy dependencies like workspace
|
|
10349
|
+
clearFiles(_project, paths = []) {
|
|
10350
|
+
const project = _project;
|
|
10109
10351
|
paths.forEach((path) => {
|
|
10110
10352
|
const files = this.filesMap.get(path);
|
|
10111
10353
|
if (!files)
|
|
@@ -10167,7 +10409,7 @@ class StateManager {
|
|
|
10167
10409
|
}
|
|
10168
10410
|
}
|
|
10169
10411
|
|
|
10170
|
-
const defaultInclude = ["
|
|
10412
|
+
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
10171
10413
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
|
|
10172
10414
|
const benchmarkConfigDefaults = {
|
|
10173
10415
|
include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
|
|
@@ -10180,6 +10422,9 @@ const defaultCoverageExcludes = [
|
|
|
10180
10422
|
"dist/**",
|
|
10181
10423
|
"packages/*/test?(s)/**",
|
|
10182
10424
|
"**/*.d.ts",
|
|
10425
|
+
"**/virtual:*",
|
|
10426
|
+
"**/__x00__*",
|
|
10427
|
+
"**/\0*",
|
|
10183
10428
|
"cypress/**",
|
|
10184
10429
|
"test?(s)/**",
|
|
10185
10430
|
"test?(-*).?(c|m)[jt]s?(x)",
|
|
@@ -10195,10 +10440,8 @@ const coverageConfigDefaults = {
|
|
|
10195
10440
|
cleanOnRerun: true,
|
|
10196
10441
|
reportsDirectory: "./coverage",
|
|
10197
10442
|
exclude: defaultCoverageExcludes,
|
|
10198
|
-
reportOnFailure:
|
|
10443
|
+
reportOnFailure: false,
|
|
10199
10444
|
reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
|
|
10200
|
-
// default extensions used by c8, plus '.vue' and '.svelte'
|
|
10201
|
-
// see https://github.com/istanbuljs/schema/blob/master/default-extension.js
|
|
10202
10445
|
extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
10203
10446
|
};
|
|
10204
10447
|
const fakeTimersDefaults = {
|
|
@@ -10251,13 +10494,73 @@ const config = {
|
|
|
10251
10494
|
dangerouslyIgnoreUnhandledErrors: false,
|
|
10252
10495
|
typecheck: {
|
|
10253
10496
|
checker: "tsc",
|
|
10254
|
-
include: ["
|
|
10497
|
+
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
|
10255
10498
|
exclude: defaultExclude
|
|
10256
10499
|
},
|
|
10257
10500
|
slowTestThreshold: 300
|
|
10258
10501
|
};
|
|
10259
10502
|
const configDefaults = Object.freeze(config);
|
|
10260
10503
|
|
|
10504
|
+
function getDefaultThreadsCount(config) {
|
|
10505
|
+
return config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
|
|
10506
|
+
}
|
|
10507
|
+
function getWorkerMemoryLimit(config) {
|
|
10508
|
+
if (config.experimentalVmWorkerMemoryLimit)
|
|
10509
|
+
return config.experimentalVmWorkerMemoryLimit;
|
|
10510
|
+
return 1 / (config.maxThreads ?? getDefaultThreadsCount(config));
|
|
10511
|
+
}
|
|
10512
|
+
function stringToBytes(input, percentageReference) {
|
|
10513
|
+
if (input === null || input === void 0)
|
|
10514
|
+
return input;
|
|
10515
|
+
if (typeof input === "string") {
|
|
10516
|
+
if (Number.isNaN(Number.parseFloat(input.slice(-1)))) {
|
|
10517
|
+
let [, numericString, trailingChars] = input.match(/(.*?)([^0-9.-]+)$/i) || [];
|
|
10518
|
+
if (trailingChars && numericString) {
|
|
10519
|
+
const numericValue = Number.parseFloat(numericString);
|
|
10520
|
+
trailingChars = trailingChars.toLowerCase();
|
|
10521
|
+
switch (trailingChars) {
|
|
10522
|
+
case "%":
|
|
10523
|
+
input = numericValue / 100;
|
|
10524
|
+
break;
|
|
10525
|
+
case "kb":
|
|
10526
|
+
case "k":
|
|
10527
|
+
return numericValue * 1e3;
|
|
10528
|
+
case "kib":
|
|
10529
|
+
return numericValue * 1024;
|
|
10530
|
+
case "mb":
|
|
10531
|
+
case "m":
|
|
10532
|
+
return numericValue * 1e3 * 1e3;
|
|
10533
|
+
case "mib":
|
|
10534
|
+
return numericValue * 1024 * 1024;
|
|
10535
|
+
case "gb":
|
|
10536
|
+
case "g":
|
|
10537
|
+
return numericValue * 1e3 * 1e3 * 1e3;
|
|
10538
|
+
case "gib":
|
|
10539
|
+
return numericValue * 1024 * 1024 * 1024;
|
|
10540
|
+
}
|
|
10541
|
+
}
|
|
10542
|
+
} else {
|
|
10543
|
+
input = Number.parseFloat(input);
|
|
10544
|
+
}
|
|
10545
|
+
}
|
|
10546
|
+
if (typeof input === "number") {
|
|
10547
|
+
if (input <= 1 && input > 0) {
|
|
10548
|
+
if (percentageReference) {
|
|
10549
|
+
return Math.floor(input * percentageReference);
|
|
10550
|
+
} else {
|
|
10551
|
+
throw new Error(
|
|
10552
|
+
"For a percentage based memory limit a percentageReference must be supplied"
|
|
10553
|
+
);
|
|
10554
|
+
}
|
|
10555
|
+
} else if (input > 1) {
|
|
10556
|
+
return Math.floor(input);
|
|
10557
|
+
} else {
|
|
10558
|
+
throw new Error('Unexpected numerical input for "experimentalVmWorkerMemoryLimit"');
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10561
|
+
return null;
|
|
10562
|
+
}
|
|
10563
|
+
|
|
10261
10564
|
class FilesStatsCache {
|
|
10262
10565
|
cache = /* @__PURE__ */ new Map();
|
|
10263
10566
|
getStats(key) {
|
|
@@ -10296,7 +10599,7 @@ class ResultsCache {
|
|
|
10296
10599
|
setConfig(root, config) {
|
|
10297
10600
|
this.root = root;
|
|
10298
10601
|
if (config)
|
|
10299
|
-
this.cachePath = resolve
|
|
10602
|
+
this.cachePath = resolve(config.dir, "results.json");
|
|
10300
10603
|
}
|
|
10301
10604
|
getResults(key) {
|
|
10302
10605
|
return this.cache.get(key);
|
|
@@ -10363,12 +10666,12 @@ class VitestCache {
|
|
|
10363
10666
|
return this.stats.getStats(key);
|
|
10364
10667
|
}
|
|
10365
10668
|
static resolveCacheDir(root, dir) {
|
|
10366
|
-
return resolve
|
|
10669
|
+
return resolve(root, slash$1(dir || "node_modules/.vitest"));
|
|
10367
10670
|
}
|
|
10368
10671
|
static async clearCache(options) {
|
|
10369
10672
|
var _a, _b;
|
|
10370
|
-
const root = resolve
|
|
10371
|
-
const configPath = options.config === false ? false : options.config ? resolve
|
|
10673
|
+
const root = resolve(options.root || process.cwd());
|
|
10674
|
+
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
10372
10675
|
const config = configPath ? (_a = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath)) == null ? void 0 : _a.config : void 0;
|
|
10373
10676
|
const cache = (_b = config == null ? void 0 : config.test) == null ? void 0 : _b.cache;
|
|
10374
10677
|
if (cache === false)
|
|
@@ -10396,7 +10699,7 @@ class BaseSequencer {
|
|
|
10396
10699
|
const shardStart = shardSize * (index - 1);
|
|
10397
10700
|
const shardEnd = shardSize * index;
|
|
10398
10701
|
return [...files].map((spec) => {
|
|
10399
|
-
const fullPath = resolve
|
|
10702
|
+
const fullPath = resolve(slash$2(config.root), slash$2(spec[1]));
|
|
10400
10703
|
const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
|
|
10401
10704
|
return {
|
|
10402
10705
|
spec,
|
|
@@ -10470,7 +10773,7 @@ function resolveApiServerConfig(options) {
|
|
|
10470
10773
|
return api;
|
|
10471
10774
|
}
|
|
10472
10775
|
function resolveConfig(mode, options, viteConfig) {
|
|
10473
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
10776
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
10474
10777
|
if (options.dom) {
|
|
10475
10778
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
10476
10779
|
console.warn(
|
|
@@ -10510,21 +10813,12 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10510
10813
|
throw new Error(`You cannot use ${inspectOption} without "threads: false" or "singleThread: true"`);
|
|
10511
10814
|
}
|
|
10512
10815
|
}
|
|
10513
|
-
if (resolved.coverage.provider === "c8"
|
|
10514
|
-
throw new Error("
|
|
10816
|
+
if (resolved.coverage.provider === "c8")
|
|
10817
|
+
throw new Error('"coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead');
|
|
10515
10818
|
if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
10516
10819
|
throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
10517
|
-
resolved.deps
|
|
10518
|
-
|
|
10519
|
-
const ssrOptions = viteConfig.ssr;
|
|
10520
|
-
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.deps.inline == null) {
|
|
10521
|
-
resolved.deps.inline = true;
|
|
10522
|
-
} else {
|
|
10523
|
-
(_b = resolved.deps).inline ?? (_b.inline = []);
|
|
10524
|
-
resolved.deps.inline.push(...extraInlineDeps);
|
|
10525
|
-
}
|
|
10526
|
-
}
|
|
10527
|
-
(_c = resolved.deps).moduleDirectories ?? (_c.moduleDirectories = ["/node_modules/"]);
|
|
10820
|
+
resolved.deps ?? (resolved.deps = {});
|
|
10821
|
+
(_b = resolved.deps).moduleDirectories ?? (_b.moduleDirectories = []);
|
|
10528
10822
|
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
|
|
10529
10823
|
if (!dir.startsWith("/"))
|
|
10530
10824
|
dir = `/${dir}`;
|
|
@@ -10532,10 +10826,49 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10532
10826
|
dir += "/";
|
|
10533
10827
|
return normalize(dir);
|
|
10534
10828
|
});
|
|
10829
|
+
if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
|
|
10830
|
+
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
10831
|
+
resolved.server ?? (resolved.server = {});
|
|
10832
|
+
(_c = resolved.server).deps ?? (_c.deps = {});
|
|
10833
|
+
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
10834
|
+
deprecatedDepsOptions.forEach((option) => {
|
|
10835
|
+
if (resolved.deps[option] === void 0)
|
|
10836
|
+
return;
|
|
10837
|
+
if (option === "fallbackCJS") {
|
|
10838
|
+
console.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. Use "server.deps.${option}" instead`));
|
|
10839
|
+
} else {
|
|
10840
|
+
const transformMode = resolved.environment === "happy-dom" || resolved.environment === "jsdom" ? "web" : "ssr";
|
|
10841
|
+
console.warn(
|
|
10842
|
+
c.yellow(
|
|
10843
|
+
`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. If you rely on vite-node directly, use "server.deps.${option}" instead. Otherwise, consider using "deps.optimizer.${transformMode}.${option === "external" ? "exclude" : "include"}"`
|
|
10844
|
+
)
|
|
10845
|
+
);
|
|
10846
|
+
}
|
|
10847
|
+
if (resolved.server.deps[option] === void 0)
|
|
10848
|
+
resolved.server.deps[option] = resolved.deps[option];
|
|
10849
|
+
});
|
|
10850
|
+
if (resolved.server.deps.inline !== true) {
|
|
10851
|
+
const ssrOptions = viteConfig.ssr;
|
|
10852
|
+
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
10853
|
+
resolved.server.deps.inline = true;
|
|
10854
|
+
} else {
|
|
10855
|
+
(_d = resolved.server.deps).inline ?? (_d.inline = []);
|
|
10856
|
+
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
10857
|
+
}
|
|
10858
|
+
}
|
|
10859
|
+
(_e = resolved.server.deps).moduleDirectories ?? (_e.moduleDirectories = []);
|
|
10860
|
+
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
10535
10861
|
if (resolved.runner) {
|
|
10536
|
-
resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve
|
|
10862
|
+
resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.runner);
|
|
10863
|
+
}
|
|
10864
|
+
if (resolved.deps.registerNodeLoader) {
|
|
10865
|
+
const transformMode = resolved.environment === "happy-dom" || resolved.environment === "jsdom" ? "web" : "ssr";
|
|
10866
|
+
console.warn(
|
|
10867
|
+
c.yellow(
|
|
10868
|
+
`${c.inverse(c.yellow(" Vitest "))} "deps.registerNodeLoader" is deprecated.If you rely on aliases inside external packages, use "deps.optimizer.${transformMode}.include" instead.`
|
|
10869
|
+
)
|
|
10870
|
+
);
|
|
10537
10871
|
}
|
|
10538
|
-
(_d = resolved.deps).registerNodeLoader ?? (_d.registerNodeLoader = false);
|
|
10539
10872
|
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
10540
10873
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
10541
10874
|
resolved.snapshotOptions = {
|
|
@@ -10545,6 +10878,10 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10545
10878
|
// resolved inside the worker
|
|
10546
10879
|
snapshotEnvironment: null
|
|
10547
10880
|
};
|
|
10881
|
+
resolved.experimentalVmWorkerMemoryLimit = stringToBytes(
|
|
10882
|
+
getWorkerMemoryLimit(resolved),
|
|
10883
|
+
totalmem()
|
|
10884
|
+
);
|
|
10548
10885
|
if (options.resolveSnapshotPath)
|
|
10549
10886
|
delete resolved.resolveSnapshotPath;
|
|
10550
10887
|
if (process.env.VITEST_MAX_THREADS)
|
|
@@ -10574,7 +10911,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10574
10911
|
}
|
|
10575
10912
|
resolved.setupFiles = toArray(resolved.setupFiles || []).map(
|
|
10576
10913
|
(file) => normalize(
|
|
10577
|
-
resolveModule(file, { paths: [resolved.root] }) ?? resolve
|
|
10914
|
+
resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
|
|
10578
10915
|
)
|
|
10579
10916
|
);
|
|
10580
10917
|
resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => relative(resolved.root, file)));
|
|
@@ -10584,11 +10921,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10584
10921
|
];
|
|
10585
10922
|
resolved.api = resolveApiServerConfig(options);
|
|
10586
10923
|
if (options.related)
|
|
10587
|
-
resolved.related = toArray(options.related).map((file) => resolve
|
|
10924
|
+
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
10588
10925
|
if (mode !== "benchmark") {
|
|
10589
10926
|
const cliReporters = toArray(resolved.reporter || []).map((reporter) => {
|
|
10590
10927
|
if (/^\.\.?\//.test(reporter))
|
|
10591
|
-
return resolve
|
|
10928
|
+
return resolve(process.cwd(), reporter);
|
|
10592
10929
|
return reporter;
|
|
10593
10930
|
});
|
|
10594
10931
|
const reporters = cliReporters.length ? cliReporters : resolved.reporters;
|
|
@@ -10600,35 +10937,36 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10600
10937
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
10601
10938
|
resolved.css ?? (resolved.css = {});
|
|
10602
10939
|
if (typeof resolved.css === "object") {
|
|
10603
|
-
(
|
|
10604
|
-
(
|
|
10940
|
+
(_f = resolved.css).modules ?? (_f.modules = {});
|
|
10941
|
+
(_g = resolved.css.modules).classNameStrategy ?? (_g.classNameStrategy = "stable");
|
|
10605
10942
|
}
|
|
10606
10943
|
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
10607
10944
|
if (resolved.cache)
|
|
10608
10945
|
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir);
|
|
10609
10946
|
resolved.sequence ?? (resolved.sequence = {});
|
|
10610
|
-
if (!((
|
|
10947
|
+
if (!((_h = resolved.sequence) == null ? void 0 : _h.sequencer)) {
|
|
10611
10948
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
10612
10949
|
}
|
|
10613
|
-
(
|
|
10950
|
+
(_i = resolved.sequence).hooks ?? (_i.hooks = "parallel");
|
|
10614
10951
|
if (resolved.sequence.sequencer === RandomSequencer)
|
|
10615
|
-
(
|
|
10952
|
+
(_j = resolved.sequence).seed ?? (_j.seed = Date.now());
|
|
10616
10953
|
resolved.typecheck = {
|
|
10617
10954
|
...configDefaults.typecheck,
|
|
10618
10955
|
...resolved.typecheck
|
|
10619
10956
|
};
|
|
10620
|
-
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve
|
|
10957
|
+
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
|
|
10621
10958
|
if (mode === "typecheck") {
|
|
10622
10959
|
resolved.include = resolved.typecheck.include;
|
|
10623
10960
|
resolved.exclude = resolved.typecheck.exclude;
|
|
10624
10961
|
}
|
|
10625
10962
|
resolved.browser ?? (resolved.browser = {});
|
|
10626
|
-
(
|
|
10627
|
-
(
|
|
10628
|
-
(
|
|
10963
|
+
(_k = resolved.browser).enabled ?? (_k.enabled = false);
|
|
10964
|
+
(_l = resolved.browser).headless ?? (_l.headless = isCI);
|
|
10965
|
+
(_m = resolved.browser).slowHijackESM ?? (_m.slowHijackESM = true);
|
|
10629
10966
|
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
10630
10967
|
port: defaultBrowserPort
|
|
10631
10968
|
};
|
|
10969
|
+
resolved.testTransformMode ?? (resolved.testTransformMode = {});
|
|
10632
10970
|
return resolved;
|
|
10633
10971
|
}
|
|
10634
10972
|
function isBrowserEnabled(config) {
|
|
@@ -10638,7 +10976,7 @@ function isBrowserEnabled(config) {
|
|
|
10638
10976
|
return ((_b = config.poolMatchGlobs) == null ? void 0 : _b.length) && config.poolMatchGlobs.some(([, pool]) => pool === "browser");
|
|
10639
10977
|
}
|
|
10640
10978
|
|
|
10641
|
-
const ESC = '\u001B[';
|
|
10979
|
+
const ESC$1 = '\u001B[';
|
|
10642
10980
|
const OSC = '\u001B]';
|
|
10643
10981
|
const BEL = '\u0007';
|
|
10644
10982
|
const SEP = ';';
|
|
@@ -10652,10 +10990,10 @@ ansiEscapes.cursorTo = (x, y) => {
|
|
|
10652
10990
|
}
|
|
10653
10991
|
|
|
10654
10992
|
if (typeof y !== 'number') {
|
|
10655
|
-
return ESC + (x + 1) + 'G';
|
|
10993
|
+
return ESC$1 + (x + 1) + 'G';
|
|
10656
10994
|
}
|
|
10657
10995
|
|
|
10658
|
-
return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
|
10996
|
+
return ESC$1 + (y + 1) + ';' + (x + 1) + 'H';
|
|
10659
10997
|
};
|
|
10660
10998
|
|
|
10661
10999
|
ansiEscapes.cursorMove = (x, y) => {
|
|
@@ -10666,33 +11004,33 @@ ansiEscapes.cursorMove = (x, y) => {
|
|
|
10666
11004
|
let returnValue = '';
|
|
10667
11005
|
|
|
10668
11006
|
if (x < 0) {
|
|
10669
|
-
returnValue += ESC + (-x) + 'D';
|
|
11007
|
+
returnValue += ESC$1 + (-x) + 'D';
|
|
10670
11008
|
} else if (x > 0) {
|
|
10671
|
-
returnValue += ESC + x + 'C';
|
|
11009
|
+
returnValue += ESC$1 + x + 'C';
|
|
10672
11010
|
}
|
|
10673
11011
|
|
|
10674
11012
|
if (y < 0) {
|
|
10675
|
-
returnValue += ESC + (-y) + 'A';
|
|
11013
|
+
returnValue += ESC$1 + (-y) + 'A';
|
|
10676
11014
|
} else if (y > 0) {
|
|
10677
|
-
returnValue += ESC + y + 'B';
|
|
11015
|
+
returnValue += ESC$1 + y + 'B';
|
|
10678
11016
|
}
|
|
10679
11017
|
|
|
10680
11018
|
return returnValue;
|
|
10681
11019
|
};
|
|
10682
11020
|
|
|
10683
|
-
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
|
|
10684
|
-
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
|
|
10685
|
-
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
|
|
10686
|
-
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
|
|
11021
|
+
ansiEscapes.cursorUp = (count = 1) => ESC$1 + count + 'A';
|
|
11022
|
+
ansiEscapes.cursorDown = (count = 1) => ESC$1 + count + 'B';
|
|
11023
|
+
ansiEscapes.cursorForward = (count = 1) => ESC$1 + count + 'C';
|
|
11024
|
+
ansiEscapes.cursorBackward = (count = 1) => ESC$1 + count + 'D';
|
|
10687
11025
|
|
|
10688
|
-
ansiEscapes.cursorLeft = ESC + 'G';
|
|
10689
|
-
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
|
|
10690
|
-
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
|
|
10691
|
-
ansiEscapes.cursorGetPosition = ESC + '6n';
|
|
10692
|
-
ansiEscapes.cursorNextLine = ESC + 'E';
|
|
10693
|
-
ansiEscapes.cursorPrevLine = ESC + 'F';
|
|
10694
|
-
ansiEscapes.cursorHide = ESC + '?25l';
|
|
10695
|
-
ansiEscapes.cursorShow = ESC + '?25h';
|
|
11026
|
+
ansiEscapes.cursorLeft = ESC$1 + 'G';
|
|
11027
|
+
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC$1 + 's';
|
|
11028
|
+
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC$1 + 'u';
|
|
11029
|
+
ansiEscapes.cursorGetPosition = ESC$1 + '6n';
|
|
11030
|
+
ansiEscapes.cursorNextLine = ESC$1 + 'E';
|
|
11031
|
+
ansiEscapes.cursorPrevLine = ESC$1 + 'F';
|
|
11032
|
+
ansiEscapes.cursorHide = ESC$1 + '?25l';
|
|
11033
|
+
ansiEscapes.cursorShow = ESC$1 + '?25h';
|
|
10696
11034
|
|
|
10697
11035
|
ansiEscapes.eraseLines = count => {
|
|
10698
11036
|
let clear = '';
|
|
@@ -10708,24 +11046,24 @@ ansiEscapes.eraseLines = count => {
|
|
|
10708
11046
|
return clear;
|
|
10709
11047
|
};
|
|
10710
11048
|
|
|
10711
|
-
ansiEscapes.eraseEndLine = ESC + 'K';
|
|
10712
|
-
ansiEscapes.eraseStartLine = ESC + '1K';
|
|
10713
|
-
ansiEscapes.eraseLine = ESC + '2K';
|
|
10714
|
-
ansiEscapes.eraseDown = ESC + 'J';
|
|
10715
|
-
ansiEscapes.eraseUp = ESC + '1J';
|
|
10716
|
-
ansiEscapes.eraseScreen = ESC + '2J';
|
|
10717
|
-
ansiEscapes.scrollUp = ESC + 'S';
|
|
10718
|
-
ansiEscapes.scrollDown = ESC + 'T';
|
|
11049
|
+
ansiEscapes.eraseEndLine = ESC$1 + 'K';
|
|
11050
|
+
ansiEscapes.eraseStartLine = ESC$1 + '1K';
|
|
11051
|
+
ansiEscapes.eraseLine = ESC$1 + '2K';
|
|
11052
|
+
ansiEscapes.eraseDown = ESC$1 + 'J';
|
|
11053
|
+
ansiEscapes.eraseUp = ESC$1 + '1J';
|
|
11054
|
+
ansiEscapes.eraseScreen = ESC$1 + '2J';
|
|
11055
|
+
ansiEscapes.scrollUp = ESC$1 + 'S';
|
|
11056
|
+
ansiEscapes.scrollDown = ESC$1 + 'T';
|
|
10719
11057
|
|
|
10720
11058
|
ansiEscapes.clearScreen = '\u001Bc';
|
|
10721
11059
|
|
|
10722
11060
|
ansiEscapes.clearTerminal = process.platform === 'win32' ?
|
|
10723
|
-
`${ansiEscapes.eraseScreen}${ESC}0f` :
|
|
11061
|
+
`${ansiEscapes.eraseScreen}${ESC$1}0f` :
|
|
10724
11062
|
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
10725
11063
|
// 2. Erases the whole screen including scrollback buffer
|
|
10726
11064
|
// 3. Moves cursor to the top-left position
|
|
10727
11065
|
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
10728
|
-
`${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
|
|
11066
|
+
`${ansiEscapes.eraseScreen}${ESC$1}3J${ESC$1}H`;
|
|
10729
11067
|
|
|
10730
11068
|
ansiEscapes.beep = BEL;
|
|
10731
11069
|
|
|
@@ -11189,633 +11527,7 @@ createLogUpdate(process$1.stdout);
|
|
|
11189
11527
|
|
|
11190
11528
|
createLogUpdate(process$1.stderr);
|
|
11191
11529
|
|
|
11192
|
-
var version = "0.
|
|
11193
|
-
|
|
11194
|
-
const comma = ','.charCodeAt(0);
|
|
11195
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
11196
|
-
const intToChar = new Uint8Array(64); // 64 possible chars.
|
|
11197
|
-
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
|
11198
|
-
for (let i = 0; i < chars.length; i++) {
|
|
11199
|
-
const c = chars.charCodeAt(i);
|
|
11200
|
-
intToChar[i] = c;
|
|
11201
|
-
charToInt[c] = i;
|
|
11202
|
-
}
|
|
11203
|
-
function decode(mappings) {
|
|
11204
|
-
const state = new Int32Array(5);
|
|
11205
|
-
const decoded = [];
|
|
11206
|
-
let index = 0;
|
|
11207
|
-
do {
|
|
11208
|
-
const semi = indexOf(mappings, index);
|
|
11209
|
-
const line = [];
|
|
11210
|
-
let sorted = true;
|
|
11211
|
-
let lastCol = 0;
|
|
11212
|
-
state[0] = 0;
|
|
11213
|
-
for (let i = index; i < semi; i++) {
|
|
11214
|
-
let seg;
|
|
11215
|
-
i = decodeInteger(mappings, i, state, 0); // genColumn
|
|
11216
|
-
const col = state[0];
|
|
11217
|
-
if (col < lastCol)
|
|
11218
|
-
sorted = false;
|
|
11219
|
-
lastCol = col;
|
|
11220
|
-
if (hasMoreVlq(mappings, i, semi)) {
|
|
11221
|
-
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
|
|
11222
|
-
i = decodeInteger(mappings, i, state, 2); // sourceLine
|
|
11223
|
-
i = decodeInteger(mappings, i, state, 3); // sourceColumn
|
|
11224
|
-
if (hasMoreVlq(mappings, i, semi)) {
|
|
11225
|
-
i = decodeInteger(mappings, i, state, 4); // namesIndex
|
|
11226
|
-
seg = [col, state[1], state[2], state[3], state[4]];
|
|
11227
|
-
}
|
|
11228
|
-
else {
|
|
11229
|
-
seg = [col, state[1], state[2], state[3]];
|
|
11230
|
-
}
|
|
11231
|
-
}
|
|
11232
|
-
else {
|
|
11233
|
-
seg = [col];
|
|
11234
|
-
}
|
|
11235
|
-
line.push(seg);
|
|
11236
|
-
}
|
|
11237
|
-
if (!sorted)
|
|
11238
|
-
sort(line);
|
|
11239
|
-
decoded.push(line);
|
|
11240
|
-
index = semi + 1;
|
|
11241
|
-
} while (index <= mappings.length);
|
|
11242
|
-
return decoded;
|
|
11243
|
-
}
|
|
11244
|
-
function indexOf(mappings, index) {
|
|
11245
|
-
const idx = mappings.indexOf(';', index);
|
|
11246
|
-
return idx === -1 ? mappings.length : idx;
|
|
11247
|
-
}
|
|
11248
|
-
function decodeInteger(mappings, pos, state, j) {
|
|
11249
|
-
let value = 0;
|
|
11250
|
-
let shift = 0;
|
|
11251
|
-
let integer = 0;
|
|
11252
|
-
do {
|
|
11253
|
-
const c = mappings.charCodeAt(pos++);
|
|
11254
|
-
integer = charToInt[c];
|
|
11255
|
-
value |= (integer & 31) << shift;
|
|
11256
|
-
shift += 5;
|
|
11257
|
-
} while (integer & 32);
|
|
11258
|
-
const shouldNegate = value & 1;
|
|
11259
|
-
value >>>= 1;
|
|
11260
|
-
if (shouldNegate) {
|
|
11261
|
-
value = -0x80000000 | -value;
|
|
11262
|
-
}
|
|
11263
|
-
state[j] += value;
|
|
11264
|
-
return pos;
|
|
11265
|
-
}
|
|
11266
|
-
function hasMoreVlq(mappings, i, length) {
|
|
11267
|
-
if (i >= length)
|
|
11268
|
-
return false;
|
|
11269
|
-
return mappings.charCodeAt(i) !== comma;
|
|
11270
|
-
}
|
|
11271
|
-
function sort(line) {
|
|
11272
|
-
line.sort(sortComparator$1);
|
|
11273
|
-
}
|
|
11274
|
-
function sortComparator$1(a, b) {
|
|
11275
|
-
return a[0] - b[0];
|
|
11276
|
-
}
|
|
11277
|
-
|
|
11278
|
-
// Matches the scheme of a URL, eg "http://"
|
|
11279
|
-
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
11280
|
-
/**
|
|
11281
|
-
* Matches the parts of a URL:
|
|
11282
|
-
* 1. Scheme, including ":", guaranteed.
|
|
11283
|
-
* 2. User/password, including "@", optional.
|
|
11284
|
-
* 3. Host, guaranteed.
|
|
11285
|
-
* 4. Port, including ":", optional.
|
|
11286
|
-
* 5. Path, including "/", optional.
|
|
11287
|
-
* 6. Query, including "?", optional.
|
|
11288
|
-
* 7. Hash, including "#", optional.
|
|
11289
|
-
*/
|
|
11290
|
-
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
11291
|
-
/**
|
|
11292
|
-
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
|
11293
|
-
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
|
11294
|
-
*
|
|
11295
|
-
* 1. Host, optional.
|
|
11296
|
-
* 2. Path, which may include "/", guaranteed.
|
|
11297
|
-
* 3. Query, including "?", optional.
|
|
11298
|
-
* 4. Hash, including "#", optional.
|
|
11299
|
-
*/
|
|
11300
|
-
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
11301
|
-
var UrlType;
|
|
11302
|
-
(function (UrlType) {
|
|
11303
|
-
UrlType[UrlType["Empty"] = 1] = "Empty";
|
|
11304
|
-
UrlType[UrlType["Hash"] = 2] = "Hash";
|
|
11305
|
-
UrlType[UrlType["Query"] = 3] = "Query";
|
|
11306
|
-
UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
|
|
11307
|
-
UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
|
|
11308
|
-
UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
|
|
11309
|
-
UrlType[UrlType["Absolute"] = 7] = "Absolute";
|
|
11310
|
-
})(UrlType || (UrlType = {}));
|
|
11311
|
-
function isAbsoluteUrl(input) {
|
|
11312
|
-
return schemeRegex.test(input);
|
|
11313
|
-
}
|
|
11314
|
-
function isSchemeRelativeUrl(input) {
|
|
11315
|
-
return input.startsWith('//');
|
|
11316
|
-
}
|
|
11317
|
-
function isAbsolutePath(input) {
|
|
11318
|
-
return input.startsWith('/');
|
|
11319
|
-
}
|
|
11320
|
-
function isFileUrl(input) {
|
|
11321
|
-
return input.startsWith('file:');
|
|
11322
|
-
}
|
|
11323
|
-
function isRelative(input) {
|
|
11324
|
-
return /^[.?#]/.test(input);
|
|
11325
|
-
}
|
|
11326
|
-
function parseAbsoluteUrl(input) {
|
|
11327
|
-
const match = urlRegex.exec(input);
|
|
11328
|
-
return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
|
|
11329
|
-
}
|
|
11330
|
-
function parseFileUrl(input) {
|
|
11331
|
-
const match = fileRegex.exec(input);
|
|
11332
|
-
const path = match[2];
|
|
11333
|
-
return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
|
|
11334
|
-
}
|
|
11335
|
-
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
11336
|
-
return {
|
|
11337
|
-
scheme,
|
|
11338
|
-
user,
|
|
11339
|
-
host,
|
|
11340
|
-
port,
|
|
11341
|
-
path,
|
|
11342
|
-
query,
|
|
11343
|
-
hash,
|
|
11344
|
-
type: UrlType.Absolute,
|
|
11345
|
-
};
|
|
11346
|
-
}
|
|
11347
|
-
function parseUrl(input) {
|
|
11348
|
-
if (isSchemeRelativeUrl(input)) {
|
|
11349
|
-
const url = parseAbsoluteUrl('http:' + input);
|
|
11350
|
-
url.scheme = '';
|
|
11351
|
-
url.type = UrlType.SchemeRelative;
|
|
11352
|
-
return url;
|
|
11353
|
-
}
|
|
11354
|
-
if (isAbsolutePath(input)) {
|
|
11355
|
-
const url = parseAbsoluteUrl('http://foo.com' + input);
|
|
11356
|
-
url.scheme = '';
|
|
11357
|
-
url.host = '';
|
|
11358
|
-
url.type = UrlType.AbsolutePath;
|
|
11359
|
-
return url;
|
|
11360
|
-
}
|
|
11361
|
-
if (isFileUrl(input))
|
|
11362
|
-
return parseFileUrl(input);
|
|
11363
|
-
if (isAbsoluteUrl(input))
|
|
11364
|
-
return parseAbsoluteUrl(input);
|
|
11365
|
-
const url = parseAbsoluteUrl('http://foo.com/' + input);
|
|
11366
|
-
url.scheme = '';
|
|
11367
|
-
url.host = '';
|
|
11368
|
-
url.type = input
|
|
11369
|
-
? input.startsWith('?')
|
|
11370
|
-
? UrlType.Query
|
|
11371
|
-
: input.startsWith('#')
|
|
11372
|
-
? UrlType.Hash
|
|
11373
|
-
: UrlType.RelativePath
|
|
11374
|
-
: UrlType.Empty;
|
|
11375
|
-
return url;
|
|
11376
|
-
}
|
|
11377
|
-
function stripPathFilename(path) {
|
|
11378
|
-
// If a path ends with a parent directory "..", then it's a relative path with excess parent
|
|
11379
|
-
// paths. It's not a file, so we can't strip it.
|
|
11380
|
-
if (path.endsWith('/..'))
|
|
11381
|
-
return path;
|
|
11382
|
-
const index = path.lastIndexOf('/');
|
|
11383
|
-
return path.slice(0, index + 1);
|
|
11384
|
-
}
|
|
11385
|
-
function mergePaths(url, base) {
|
|
11386
|
-
normalizePath(base, base.type);
|
|
11387
|
-
// If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
|
|
11388
|
-
// path).
|
|
11389
|
-
if (url.path === '/') {
|
|
11390
|
-
url.path = base.path;
|
|
11391
|
-
}
|
|
11392
|
-
else {
|
|
11393
|
-
// Resolution happens relative to the base path's directory, not the file.
|
|
11394
|
-
url.path = stripPathFilename(base.path) + url.path;
|
|
11395
|
-
}
|
|
11396
|
-
}
|
|
11397
|
-
/**
|
|
11398
|
-
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
|
11399
|
-
* "foo/.". We need to normalize to a standard representation.
|
|
11400
|
-
*/
|
|
11401
|
-
function normalizePath(url, type) {
|
|
11402
|
-
const rel = type <= UrlType.RelativePath;
|
|
11403
|
-
const pieces = url.path.split('/');
|
|
11404
|
-
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
|
11405
|
-
// pieces[0] is an empty string.
|
|
11406
|
-
let pointer = 1;
|
|
11407
|
-
// Positive is the number of real directories we've output, used for popping a parent directory.
|
|
11408
|
-
// Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
|
|
11409
|
-
let positive = 0;
|
|
11410
|
-
// We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
|
|
11411
|
-
// generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
|
|
11412
|
-
// real directory, we won't need to append, unless the other conditions happen again.
|
|
11413
|
-
let addTrailingSlash = false;
|
|
11414
|
-
for (let i = 1; i < pieces.length; i++) {
|
|
11415
|
-
const piece = pieces[i];
|
|
11416
|
-
// An empty directory, could be a trailing slash, or just a double "//" in the path.
|
|
11417
|
-
if (!piece) {
|
|
11418
|
-
addTrailingSlash = true;
|
|
11419
|
-
continue;
|
|
11420
|
-
}
|
|
11421
|
-
// If we encounter a real directory, then we don't need to append anymore.
|
|
11422
|
-
addTrailingSlash = false;
|
|
11423
|
-
// A current directory, which we can always drop.
|
|
11424
|
-
if (piece === '.')
|
|
11425
|
-
continue;
|
|
11426
|
-
// A parent directory, we need to see if there are any real directories we can pop. Else, we
|
|
11427
|
-
// have an excess of parents, and we'll need to keep the "..".
|
|
11428
|
-
if (piece === '..') {
|
|
11429
|
-
if (positive) {
|
|
11430
|
-
addTrailingSlash = true;
|
|
11431
|
-
positive--;
|
|
11432
|
-
pointer--;
|
|
11433
|
-
}
|
|
11434
|
-
else if (rel) {
|
|
11435
|
-
// If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
|
|
11436
|
-
// URL, protocol relative URL, or an absolute path, we don't need to keep excess.
|
|
11437
|
-
pieces[pointer++] = piece;
|
|
11438
|
-
}
|
|
11439
|
-
continue;
|
|
11440
|
-
}
|
|
11441
|
-
// We've encountered a real directory. Move it to the next insertion pointer, which accounts for
|
|
11442
|
-
// any popped or dropped directories.
|
|
11443
|
-
pieces[pointer++] = piece;
|
|
11444
|
-
positive++;
|
|
11445
|
-
}
|
|
11446
|
-
let path = '';
|
|
11447
|
-
for (let i = 1; i < pointer; i++) {
|
|
11448
|
-
path += '/' + pieces[i];
|
|
11449
|
-
}
|
|
11450
|
-
if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
|
|
11451
|
-
path += '/';
|
|
11452
|
-
}
|
|
11453
|
-
url.path = path;
|
|
11454
|
-
}
|
|
11455
|
-
/**
|
|
11456
|
-
* Attempts to resolve `input` URL/path relative to `base`.
|
|
11457
|
-
*/
|
|
11458
|
-
function resolve$1(input, base) {
|
|
11459
|
-
if (!input && !base)
|
|
11460
|
-
return '';
|
|
11461
|
-
const url = parseUrl(input);
|
|
11462
|
-
let inputType = url.type;
|
|
11463
|
-
if (base && inputType !== UrlType.Absolute) {
|
|
11464
|
-
const baseUrl = parseUrl(base);
|
|
11465
|
-
const baseType = baseUrl.type;
|
|
11466
|
-
switch (inputType) {
|
|
11467
|
-
case UrlType.Empty:
|
|
11468
|
-
url.hash = baseUrl.hash;
|
|
11469
|
-
// fall through
|
|
11470
|
-
case UrlType.Hash:
|
|
11471
|
-
url.query = baseUrl.query;
|
|
11472
|
-
// fall through
|
|
11473
|
-
case UrlType.Query:
|
|
11474
|
-
case UrlType.RelativePath:
|
|
11475
|
-
mergePaths(url, baseUrl);
|
|
11476
|
-
// fall through
|
|
11477
|
-
case UrlType.AbsolutePath:
|
|
11478
|
-
// The host, user, and port are joined, you can't copy one without the others.
|
|
11479
|
-
url.user = baseUrl.user;
|
|
11480
|
-
url.host = baseUrl.host;
|
|
11481
|
-
url.port = baseUrl.port;
|
|
11482
|
-
// fall through
|
|
11483
|
-
case UrlType.SchemeRelative:
|
|
11484
|
-
// The input doesn't have a schema at least, so we need to copy at least that over.
|
|
11485
|
-
url.scheme = baseUrl.scheme;
|
|
11486
|
-
}
|
|
11487
|
-
if (baseType > inputType)
|
|
11488
|
-
inputType = baseType;
|
|
11489
|
-
}
|
|
11490
|
-
normalizePath(url, inputType);
|
|
11491
|
-
const queryHash = url.query + url.hash;
|
|
11492
|
-
switch (inputType) {
|
|
11493
|
-
// This is impossible, because of the empty checks at the start of the function.
|
|
11494
|
-
// case UrlType.Empty:
|
|
11495
|
-
case UrlType.Hash:
|
|
11496
|
-
case UrlType.Query:
|
|
11497
|
-
return queryHash;
|
|
11498
|
-
case UrlType.RelativePath: {
|
|
11499
|
-
// The first char is always a "/", and we need it to be relative.
|
|
11500
|
-
const path = url.path.slice(1);
|
|
11501
|
-
if (!path)
|
|
11502
|
-
return queryHash || '.';
|
|
11503
|
-
if (isRelative(base || input) && !isRelative(path)) {
|
|
11504
|
-
// If base started with a leading ".", or there is no base and input started with a ".",
|
|
11505
|
-
// then we need to ensure that the relative path starts with a ".". We don't know if
|
|
11506
|
-
// relative starts with a "..", though, so check before prepending.
|
|
11507
|
-
return './' + path + queryHash;
|
|
11508
|
-
}
|
|
11509
|
-
return path + queryHash;
|
|
11510
|
-
}
|
|
11511
|
-
case UrlType.AbsolutePath:
|
|
11512
|
-
return url.path + queryHash;
|
|
11513
|
-
default:
|
|
11514
|
-
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
|
11515
|
-
}
|
|
11516
|
-
}
|
|
11517
|
-
|
|
11518
|
-
function resolve(input, base) {
|
|
11519
|
-
// The base is always treated as a directory, if it's not empty.
|
|
11520
|
-
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
|
11521
|
-
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
11522
|
-
if (base && !base.endsWith('/'))
|
|
11523
|
-
base += '/';
|
|
11524
|
-
return resolve$1(input, base);
|
|
11525
|
-
}
|
|
11526
|
-
|
|
11527
|
-
/**
|
|
11528
|
-
* Removes everything after the last "/", but leaves the slash.
|
|
11529
|
-
*/
|
|
11530
|
-
function stripFilename(path) {
|
|
11531
|
-
if (!path)
|
|
11532
|
-
return '';
|
|
11533
|
-
const index = path.lastIndexOf('/');
|
|
11534
|
-
return path.slice(0, index + 1);
|
|
11535
|
-
}
|
|
11536
|
-
|
|
11537
|
-
const COLUMN = 0;
|
|
11538
|
-
const SOURCES_INDEX = 1;
|
|
11539
|
-
const SOURCE_LINE = 2;
|
|
11540
|
-
const SOURCE_COLUMN = 3;
|
|
11541
|
-
const REV_GENERATED_LINE = 1;
|
|
11542
|
-
const REV_GENERATED_COLUMN = 2;
|
|
11543
|
-
|
|
11544
|
-
function maybeSort(mappings, owned) {
|
|
11545
|
-
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
11546
|
-
if (unsortedIndex === mappings.length)
|
|
11547
|
-
return mappings;
|
|
11548
|
-
// If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If
|
|
11549
|
-
// not, we do not want to modify the consumer's input array.
|
|
11550
|
-
if (!owned)
|
|
11551
|
-
mappings = mappings.slice();
|
|
11552
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
11553
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
11554
|
-
}
|
|
11555
|
-
return mappings;
|
|
11556
|
-
}
|
|
11557
|
-
function nextUnsortedSegmentLine(mappings, start) {
|
|
11558
|
-
for (let i = start; i < mappings.length; i++) {
|
|
11559
|
-
if (!isSorted(mappings[i]))
|
|
11560
|
-
return i;
|
|
11561
|
-
}
|
|
11562
|
-
return mappings.length;
|
|
11563
|
-
}
|
|
11564
|
-
function isSorted(line) {
|
|
11565
|
-
for (let j = 1; j < line.length; j++) {
|
|
11566
|
-
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
11567
|
-
return false;
|
|
11568
|
-
}
|
|
11569
|
-
}
|
|
11570
|
-
return true;
|
|
11571
|
-
}
|
|
11572
|
-
function sortSegments(line, owned) {
|
|
11573
|
-
if (!owned)
|
|
11574
|
-
line = line.slice();
|
|
11575
|
-
return line.sort(sortComparator);
|
|
11576
|
-
}
|
|
11577
|
-
function sortComparator(a, b) {
|
|
11578
|
-
return a[COLUMN] - b[COLUMN];
|
|
11579
|
-
}
|
|
11580
|
-
|
|
11581
|
-
let found = false;
|
|
11582
|
-
/**
|
|
11583
|
-
* A binary search implementation that returns the index if a match is found.
|
|
11584
|
-
* If no match is found, then the left-index (the index associated with the item that comes just
|
|
11585
|
-
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
|
11586
|
-
* the next index:
|
|
11587
|
-
*
|
|
11588
|
-
* ```js
|
|
11589
|
-
* const array = [1, 3];
|
|
11590
|
-
* const needle = 2;
|
|
11591
|
-
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
|
11592
|
-
*
|
|
11593
|
-
* assert.equal(index, 0);
|
|
11594
|
-
* array.splice(index + 1, 0, needle);
|
|
11595
|
-
* assert.deepEqual(array, [1, 2, 3]);
|
|
11596
|
-
* ```
|
|
11597
|
-
*/
|
|
11598
|
-
function binarySearch(haystack, needle, low, high) {
|
|
11599
|
-
while (low <= high) {
|
|
11600
|
-
const mid = low + ((high - low) >> 1);
|
|
11601
|
-
const cmp = haystack[mid][COLUMN] - needle;
|
|
11602
|
-
if (cmp === 0) {
|
|
11603
|
-
found = true;
|
|
11604
|
-
return mid;
|
|
11605
|
-
}
|
|
11606
|
-
if (cmp < 0) {
|
|
11607
|
-
low = mid + 1;
|
|
11608
|
-
}
|
|
11609
|
-
else {
|
|
11610
|
-
high = mid - 1;
|
|
11611
|
-
}
|
|
11612
|
-
}
|
|
11613
|
-
found = false;
|
|
11614
|
-
return low - 1;
|
|
11615
|
-
}
|
|
11616
|
-
function upperBound(haystack, needle, index) {
|
|
11617
|
-
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
11618
|
-
if (haystack[i][COLUMN] !== needle)
|
|
11619
|
-
break;
|
|
11620
|
-
}
|
|
11621
|
-
return index;
|
|
11622
|
-
}
|
|
11623
|
-
function lowerBound(haystack, needle, index) {
|
|
11624
|
-
for (let i = index - 1; i >= 0; index = i--) {
|
|
11625
|
-
if (haystack[i][COLUMN] !== needle)
|
|
11626
|
-
break;
|
|
11627
|
-
}
|
|
11628
|
-
return index;
|
|
11629
|
-
}
|
|
11630
|
-
function memoizedState() {
|
|
11631
|
-
return {
|
|
11632
|
-
lastKey: -1,
|
|
11633
|
-
lastNeedle: -1,
|
|
11634
|
-
lastIndex: -1,
|
|
11635
|
-
};
|
|
11636
|
-
}
|
|
11637
|
-
/**
|
|
11638
|
-
* This overly complicated beast is just to record the last tested line/column and the resulting
|
|
11639
|
-
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
|
11640
|
-
*/
|
|
11641
|
-
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
11642
|
-
const { lastKey, lastNeedle, lastIndex } = state;
|
|
11643
|
-
let low = 0;
|
|
11644
|
-
let high = haystack.length - 1;
|
|
11645
|
-
if (key === lastKey) {
|
|
11646
|
-
if (needle === lastNeedle) {
|
|
11647
|
-
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
11648
|
-
return lastIndex;
|
|
11649
|
-
}
|
|
11650
|
-
if (needle >= lastNeedle) {
|
|
11651
|
-
// lastIndex may be -1 if the previous needle was not found.
|
|
11652
|
-
low = lastIndex === -1 ? 0 : lastIndex;
|
|
11653
|
-
}
|
|
11654
|
-
else {
|
|
11655
|
-
high = lastIndex;
|
|
11656
|
-
}
|
|
11657
|
-
}
|
|
11658
|
-
state.lastKey = key;
|
|
11659
|
-
state.lastNeedle = needle;
|
|
11660
|
-
return (state.lastIndex = binarySearch(haystack, needle, low, high));
|
|
11661
|
-
}
|
|
11662
|
-
|
|
11663
|
-
// Rebuilds the original source files, with mappings that are ordered by source line/column instead
|
|
11664
|
-
// of generated line/column.
|
|
11665
|
-
function buildBySources(decoded, memos) {
|
|
11666
|
-
const sources = memos.map(buildNullArray);
|
|
11667
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
11668
|
-
const line = decoded[i];
|
|
11669
|
-
for (let j = 0; j < line.length; j++) {
|
|
11670
|
-
const seg = line[j];
|
|
11671
|
-
if (seg.length === 1)
|
|
11672
|
-
continue;
|
|
11673
|
-
const sourceIndex = seg[SOURCES_INDEX];
|
|
11674
|
-
const sourceLine = seg[SOURCE_LINE];
|
|
11675
|
-
const sourceColumn = seg[SOURCE_COLUMN];
|
|
11676
|
-
const originalSource = sources[sourceIndex];
|
|
11677
|
-
const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = []));
|
|
11678
|
-
const memo = memos[sourceIndex];
|
|
11679
|
-
// The binary search either found a match, or it found the left-index just before where the
|
|
11680
|
-
// segment should go. Either way, we want to insert after that. And there may be multiple
|
|
11681
|
-
// generated segments associated with an original location, so there may need to move several
|
|
11682
|
-
// indexes before we find where we need to insert.
|
|
11683
|
-
const index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
|
|
11684
|
-
insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]);
|
|
11685
|
-
}
|
|
11686
|
-
}
|
|
11687
|
-
return sources;
|
|
11688
|
-
}
|
|
11689
|
-
function insert(array, index, value) {
|
|
11690
|
-
for (let i = array.length; i > index; i--) {
|
|
11691
|
-
array[i] = array[i - 1];
|
|
11692
|
-
}
|
|
11693
|
-
array[index] = value;
|
|
11694
|
-
}
|
|
11695
|
-
// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like
|
|
11696
|
-
// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations.
|
|
11697
|
-
// Numeric properties on objects are magically sorted in ascending order by the engine regardless of
|
|
11698
|
-
// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending
|
|
11699
|
-
// order when iterating with for-in.
|
|
11700
|
-
function buildNullArray() {
|
|
11701
|
-
return { __proto__: null };
|
|
11702
|
-
}
|
|
11703
|
-
|
|
11704
|
-
const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
|
|
11705
|
-
const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
|
|
11706
|
-
const LEAST_UPPER_BOUND = -1;
|
|
11707
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
11708
|
-
/**
|
|
11709
|
-
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
|
11710
|
-
*/
|
|
11711
|
-
let decodedMappings;
|
|
11712
|
-
/**
|
|
11713
|
-
* Finds the generated line/column position of the provided source/line/column source position.
|
|
11714
|
-
*/
|
|
11715
|
-
let generatedPositionFor;
|
|
11716
|
-
class TraceMap {
|
|
11717
|
-
constructor(map, mapUrl) {
|
|
11718
|
-
const isString = typeof map === 'string';
|
|
11719
|
-
if (!isString && map._decodedMemo)
|
|
11720
|
-
return map;
|
|
11721
|
-
const parsed = (isString ? JSON.parse(map) : map);
|
|
11722
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
11723
|
-
this.version = version;
|
|
11724
|
-
this.file = file;
|
|
11725
|
-
this.names = names;
|
|
11726
|
-
this.sourceRoot = sourceRoot;
|
|
11727
|
-
this.sources = sources;
|
|
11728
|
-
this.sourcesContent = sourcesContent;
|
|
11729
|
-
const from = resolve(sourceRoot || '', stripFilename(mapUrl));
|
|
11730
|
-
this.resolvedSources = sources.map((s) => resolve(s || '', from));
|
|
11731
|
-
const { mappings } = parsed;
|
|
11732
|
-
if (typeof mappings === 'string') {
|
|
11733
|
-
this._encoded = mappings;
|
|
11734
|
-
this._decoded = undefined;
|
|
11735
|
-
}
|
|
11736
|
-
else {
|
|
11737
|
-
this._encoded = undefined;
|
|
11738
|
-
this._decoded = maybeSort(mappings, isString);
|
|
11739
|
-
}
|
|
11740
|
-
this._decodedMemo = memoizedState();
|
|
11741
|
-
this._bySources = undefined;
|
|
11742
|
-
this._bySourceMemos = undefined;
|
|
11743
|
-
}
|
|
11744
|
-
}
|
|
11745
|
-
(() => {
|
|
11746
|
-
decodedMappings = (map) => {
|
|
11747
|
-
return (map._decoded || (map._decoded = decode(map._encoded)));
|
|
11748
|
-
};
|
|
11749
|
-
generatedPositionFor = (map, { source, line, column, bias }) => {
|
|
11750
|
-
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
|
|
11751
|
-
};
|
|
11752
|
-
function generatedPosition(map, source, line, column, bias, all) {
|
|
11753
|
-
line--;
|
|
11754
|
-
if (line < 0)
|
|
11755
|
-
throw new Error(LINE_GTR_ZERO);
|
|
11756
|
-
if (column < 0)
|
|
11757
|
-
throw new Error(COL_GTR_EQ_ZERO);
|
|
11758
|
-
const { sources, resolvedSources } = map;
|
|
11759
|
-
let sourceIndex = sources.indexOf(source);
|
|
11760
|
-
if (sourceIndex === -1)
|
|
11761
|
-
sourceIndex = resolvedSources.indexOf(source);
|
|
11762
|
-
if (sourceIndex === -1)
|
|
11763
|
-
return all ? [] : GMapping(null, null);
|
|
11764
|
-
const generated = (map._bySources || (map._bySources = buildBySources(decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
|
|
11765
|
-
const segments = generated[sourceIndex][line];
|
|
11766
|
-
if (segments == null)
|
|
11767
|
-
return all ? [] : GMapping(null, null);
|
|
11768
|
-
const memo = map._bySourceMemos[sourceIndex];
|
|
11769
|
-
if (all)
|
|
11770
|
-
return sliceGeneratedPositions(segments, memo, line, column, bias);
|
|
11771
|
-
const index = traceSegmentInternal(segments, memo, line, column, bias);
|
|
11772
|
-
if (index === -1)
|
|
11773
|
-
return GMapping(null, null);
|
|
11774
|
-
const segment = segments[index];
|
|
11775
|
-
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
|
|
11776
|
-
}
|
|
11777
|
-
})();
|
|
11778
|
-
function GMapping(line, column) {
|
|
11779
|
-
return { line, column };
|
|
11780
|
-
}
|
|
11781
|
-
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
11782
|
-
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
11783
|
-
if (found) {
|
|
11784
|
-
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
11785
|
-
}
|
|
11786
|
-
else if (bias === LEAST_UPPER_BOUND)
|
|
11787
|
-
index++;
|
|
11788
|
-
if (index === -1 || index === segments.length)
|
|
11789
|
-
return -1;
|
|
11790
|
-
return index;
|
|
11791
|
-
}
|
|
11792
|
-
function sliceGeneratedPositions(segments, memo, line, column, bias) {
|
|
11793
|
-
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
|
|
11794
|
-
// We ignored the bias when tracing the segment so that we're guarnateed to find the first (in
|
|
11795
|
-
// insertion order) segment that matched. Even if we did respect the bias when tracing, we would
|
|
11796
|
-
// still need to call `lowerBound()` to find the first segment, which is slower than just looking
|
|
11797
|
-
// for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the
|
|
11798
|
-
// binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to
|
|
11799
|
-
// match LEAST_UPPER_BOUND.
|
|
11800
|
-
if (!found && bias === LEAST_UPPER_BOUND)
|
|
11801
|
-
min++;
|
|
11802
|
-
if (min === -1 || min === segments.length)
|
|
11803
|
-
return [];
|
|
11804
|
-
// We may have found the segment that started at an earlier column. If this is the case, then we
|
|
11805
|
-
// need to slice all generated segments that match _that_ column, because all such segments span
|
|
11806
|
-
// to our desired column.
|
|
11807
|
-
const matchedColumn = found ? column : segments[min][COLUMN];
|
|
11808
|
-
// The binary search is not guaranteed to find the lower bound when a match wasn't found.
|
|
11809
|
-
if (!found)
|
|
11810
|
-
min = lowerBound(segments, matchedColumn, min);
|
|
11811
|
-
const max = upperBound(segments, matchedColumn, min);
|
|
11812
|
-
const result = [];
|
|
11813
|
-
for (; min <= max; min++) {
|
|
11814
|
-
const segment = segments[min];
|
|
11815
|
-
result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
|
|
11816
|
-
}
|
|
11817
|
-
return result;
|
|
11818
|
-
}
|
|
11530
|
+
var version = "0.34.0";
|
|
11819
11531
|
|
|
11820
11532
|
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d$1(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d$1(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
11821
11533
|
|
|
@@ -11860,7 +11572,7 @@ async function makeTscErrorInfo(errInfo) {
|
|
|
11860
11572
|
}
|
|
11861
11573
|
async function getTsconfig(root, config) {
|
|
11862
11574
|
const configName = config.tsconfig ? basename(config.tsconfig) : void 0;
|
|
11863
|
-
const configSearchPath = config.tsconfig ? dirname(resolve
|
|
11575
|
+
const configSearchPath = config.tsconfig ? dirname(resolve(root, config.tsconfig)) : root;
|
|
11864
11576
|
const tsconfig = Te(configSearchPath, configName);
|
|
11865
11577
|
if (!tsconfig)
|
|
11866
11578
|
throw new Error("no tsconfig.json found");
|
|
@@ -12183,7 +11895,7 @@ class Typechecker {
|
|
|
12183
11895
|
const errorsMap = await getRawErrsMapFromTsCompile(output);
|
|
12184
11896
|
const typesErrors = /* @__PURE__ */ new Map();
|
|
12185
11897
|
errorsMap.forEach((errors, path) => {
|
|
12186
|
-
const filepath = resolve
|
|
11898
|
+
const filepath = resolve(this.ctx.config.root, path);
|
|
12187
11899
|
const suiteErrors = errors.map((info) => {
|
|
12188
11900
|
const limit = Error.stackTraceLimit;
|
|
12189
11901
|
Error.stackTraceLimit = 0;
|
|
@@ -12292,8 +12004,9 @@ class Typechecker {
|
|
|
12292
12004
|
}
|
|
12293
12005
|
}
|
|
12294
12006
|
|
|
12295
|
-
async function printError(error,
|
|
12007
|
+
async function printError(error, project, options) {
|
|
12296
12008
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
12009
|
+
const logger = options.logger;
|
|
12297
12010
|
let e = error;
|
|
12298
12011
|
if (isPrimitive(e)) {
|
|
12299
12012
|
e = {
|
|
@@ -12308,25 +12021,31 @@ async function printError(error, ctx, options = {}) {
|
|
|
12308
12021
|
stack: error2.stack
|
|
12309
12022
|
};
|
|
12310
12023
|
}
|
|
12311
|
-
if (!
|
|
12312
|
-
return printErrorMessage(e,
|
|
12313
|
-
const
|
|
12024
|
+
if (!project)
|
|
12025
|
+
return printErrorMessage(e, logger);
|
|
12026
|
+
const parserOptions = {
|
|
12027
|
+
// only browser stack traces require remapping
|
|
12028
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
12029
|
+
};
|
|
12030
|
+
if (fullStack)
|
|
12031
|
+
parserOptions.ignoreStackEntries = [];
|
|
12032
|
+
const stacks = parseErrorStacktrace(e, parserOptions);
|
|
12314
12033
|
const nearest = error instanceof TypeCheckError ? error.stacks[0] : stacks.find(
|
|
12315
|
-
(stack) =>
|
|
12034
|
+
(stack) => project.getModuleById(stack.file) && existsSync(stack.file)
|
|
12316
12035
|
);
|
|
12317
12036
|
const errorProperties = getErrorProperties(e);
|
|
12318
12037
|
if (type)
|
|
12319
|
-
printErrorType(type, ctx);
|
|
12320
|
-
printErrorMessage(e,
|
|
12038
|
+
printErrorType(type, project.ctx);
|
|
12039
|
+
printErrorMessage(e, logger);
|
|
12321
12040
|
if (e.diff)
|
|
12322
|
-
displayDiff(e.diff,
|
|
12041
|
+
displayDiff(e.diff, logger.console);
|
|
12323
12042
|
if (e.frame) {
|
|
12324
|
-
|
|
12043
|
+
logger.error(c.yellow(e.frame));
|
|
12325
12044
|
} else {
|
|
12326
|
-
printStack(
|
|
12045
|
+
printStack(project, stacks, nearest, errorProperties, (s) => {
|
|
12327
12046
|
if (showCodeFrame && s === nearest && nearest) {
|
|
12328
12047
|
const sourceCode = readFileSync(nearest.file, "utf-8");
|
|
12329
|
-
|
|
12048
|
+
logger.error(generateCodeFrame(sourceCode, 4, s.line, s.column));
|
|
12330
12049
|
}
|
|
12331
12050
|
});
|
|
12332
12051
|
}
|
|
@@ -12334,20 +12053,20 @@ async function printError(error, ctx, options = {}) {
|
|
|
12334
12053
|
const testName = e.VITEST_TEST_NAME;
|
|
12335
12054
|
const afterEnvTeardown = e.VITEST_AFTER_ENV_TEARDOWN;
|
|
12336
12055
|
if (testPath)
|
|
12337
|
-
|
|
12056
|
+
logger.error(c.red(`This error originated in "${c.bold(testPath)}" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.`));
|
|
12338
12057
|
if (testName) {
|
|
12339
|
-
|
|
12058
|
+
logger.error(c.red(`The latest test that might've caused the error is "${c.bold(testName)}". It might mean one of the following:
|
|
12340
12059
|
- The error was thrown, while Vitest was running this test.
|
|
12341
12060
|
- This was the last recorded test before the error was thrown, if error originated after test finished its execution.`));
|
|
12342
12061
|
}
|
|
12343
12062
|
if (afterEnvTeardown) {
|
|
12344
|
-
|
|
12063
|
+
logger.error(c.red("This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:\n- cancel timeouts using clearTimeout and clearInterval\n- wait for promises to resolve using the await keyword"));
|
|
12345
12064
|
}
|
|
12346
12065
|
if (typeof e.cause === "object" && e.cause && "name" in e.cause) {
|
|
12347
12066
|
e.cause.name = `Caused by: ${e.cause.name}`;
|
|
12348
|
-
await printError(e.cause,
|
|
12067
|
+
await printError(e.cause, project, { fullStack, showCodeFrame: false, logger: options.logger });
|
|
12349
12068
|
}
|
|
12350
|
-
handleImportOutsideModuleError(e.stack || e.stackStr || "",
|
|
12069
|
+
handleImportOutsideModuleError(e.stack || e.stackStr || "", logger);
|
|
12351
12070
|
}
|
|
12352
12071
|
function printErrorType(type, ctx) {
|
|
12353
12072
|
ctx.logger.error(`
|
|
@@ -12384,7 +12103,7 @@ const esmErrors = [
|
|
|
12384
12103
|
"Cannot use import statement outside a module",
|
|
12385
12104
|
"Unexpected token 'export'"
|
|
12386
12105
|
];
|
|
12387
|
-
function handleImportOutsideModuleError(stack,
|
|
12106
|
+
function handleImportOutsideModuleError(stack, logger) {
|
|
12388
12107
|
if (!esmErrors.some((e) => stack.includes(e)))
|
|
12389
12108
|
return;
|
|
12390
12109
|
const path = normalize(stack.split("\n")[0].trim());
|
|
@@ -12394,9 +12113,9 @@ function handleImportOutsideModuleError(stack, ctx) {
|
|
|
12394
12113
|
else
|
|
12395
12114
|
name = name.split("/")[0];
|
|
12396
12115
|
if (name)
|
|
12397
|
-
printModuleWarningForPackage(
|
|
12116
|
+
printModuleWarningForPackage(logger, path, name);
|
|
12398
12117
|
else
|
|
12399
|
-
printModuleWarningForSourceCode(
|
|
12118
|
+
printModuleWarningForSourceCode(logger, path);
|
|
12400
12119
|
}
|
|
12401
12120
|
function printModuleWarningForPackage(logger, path, name) {
|
|
12402
12121
|
logger.error(c.yellow(
|
|
@@ -12429,17 +12148,21 @@ ${diff}
|
|
|
12429
12148
|
}
|
|
12430
12149
|
function printErrorMessage(error, logger) {
|
|
12431
12150
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
12151
|
+
if (!error.message) {
|
|
12152
|
+
logger.error(error);
|
|
12153
|
+
return;
|
|
12154
|
+
}
|
|
12432
12155
|
if (error.message.length > 5e3) {
|
|
12433
12156
|
logger.error(`${c.red(c.bold(errorName))}: ${error.message}`);
|
|
12434
12157
|
} else {
|
|
12435
12158
|
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
|
|
12436
12159
|
}
|
|
12437
12160
|
}
|
|
12438
|
-
function printStack(
|
|
12439
|
-
const logger = ctx.logger;
|
|
12161
|
+
function printStack(project, stack, highlight, errorProperties, onStack) {
|
|
12162
|
+
const logger = project.ctx.logger;
|
|
12440
12163
|
for (const frame of stack) {
|
|
12441
12164
|
const color = frame === highlight ? c.cyan : c.gray;
|
|
12442
|
-
const path = relative(
|
|
12165
|
+
const path = relative(project.config.root, frame.file);
|
|
12443
12166
|
logger.error(color(` ${c.dim(F_POINTER)} ${[frame.method, `${path}:${c.dim(`${frame.line}:${frame.column}`)}`].filter(Boolean).join(" ")}`));
|
|
12444
12167
|
onStack == null ? void 0 : onStack(frame);
|
|
12445
12168
|
}
|
|
@@ -12448,7 +12171,7 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
|
|
|
12448
12171
|
const hasProperties = Object.keys(errorProperties).length > 0;
|
|
12449
12172
|
if (hasProperties) {
|
|
12450
12173
|
logger.error(c.red(c.dim(divider())));
|
|
12451
|
-
const propertiesString =
|
|
12174
|
+
const propertiesString = inspect(errorProperties);
|
|
12452
12175
|
logger.error(c.red(c.bold("Serialized Error:")), c.gray(propertiesString));
|
|
12453
12176
|
}
|
|
12454
12177
|
}
|
|
@@ -12493,6 +12216,11 @@ function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range =
|
|
|
12493
12216
|
return res.join("\n");
|
|
12494
12217
|
}
|
|
12495
12218
|
|
|
12219
|
+
const ESC = "\x1B[";
|
|
12220
|
+
const ERASE_DOWN = `${ESC}J`;
|
|
12221
|
+
const ERASE_SCROLLBACK = `${ESC}3J`;
|
|
12222
|
+
const CURSOR_TO_START = `${ESC}1;1H`;
|
|
12223
|
+
const CLEAR_SCREEN = "\x1Bc";
|
|
12496
12224
|
class Logger {
|
|
12497
12225
|
constructor(ctx, console = globalThis.console) {
|
|
12498
12226
|
this.ctx = ctx;
|
|
@@ -12519,7 +12247,7 @@ class Logger {
|
|
|
12519
12247
|
this.console.log(message);
|
|
12520
12248
|
return;
|
|
12521
12249
|
}
|
|
12522
|
-
this.console.log(
|
|
12250
|
+
this.console.log(`${ERASE_SCROLLBACK}${CLEAR_SCREEN}${message}`);
|
|
12523
12251
|
}
|
|
12524
12252
|
clearScreen(message, force = false) {
|
|
12525
12253
|
if (this.ctx.server.config.clearScreen === false) {
|
|
@@ -12535,16 +12263,20 @@ class Logger {
|
|
|
12535
12263
|
return;
|
|
12536
12264
|
const log = this._clearScreenPending;
|
|
12537
12265
|
this._clearScreenPending = void 0;
|
|
12538
|
-
this.console.log(
|
|
12266
|
+
this.console.log(`${CURSOR_TO_START}${ERASE_DOWN}${log}`);
|
|
12539
12267
|
}
|
|
12540
|
-
printError(err,
|
|
12541
|
-
|
|
12268
|
+
printError(err, options = {}) {
|
|
12269
|
+
const { fullStack = false, type } = options;
|
|
12270
|
+
const project = options.project ?? this.ctx.getCoreWorkspaceProject() ?? this.ctx.projects[0];
|
|
12271
|
+
return printError(err, project, {
|
|
12542
12272
|
fullStack,
|
|
12543
12273
|
type,
|
|
12544
|
-
showCodeFrame: true
|
|
12274
|
+
showCodeFrame: true,
|
|
12275
|
+
logger: this
|
|
12545
12276
|
});
|
|
12546
12277
|
}
|
|
12547
12278
|
printNoTestFound(filters) {
|
|
12279
|
+
var _a;
|
|
12548
12280
|
const config = this.ctx.config;
|
|
12549
12281
|
const comma = c.dim(", ");
|
|
12550
12282
|
if (filters == null ? void 0 : filters.length)
|
|
@@ -12555,12 +12287,17 @@ class Logger {
|
|
|
12555
12287
|
this.console.error(c.dim("exclude: ") + c.yellow(config.exclude.join(comma)));
|
|
12556
12288
|
if (config.watchExclude)
|
|
12557
12289
|
this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
|
|
12558
|
-
if (config.
|
|
12559
|
-
this.log(`No ${config.mode} files found
|
|
12290
|
+
if (config.watch && (config.changed || ((_a = config.related) == null ? void 0 : _a.length))) {
|
|
12291
|
+
this.log(`No affected ${config.mode} files found
|
|
12560
12292
|
`);
|
|
12561
|
-
else
|
|
12562
|
-
|
|
12293
|
+
} else {
|
|
12294
|
+
if (config.passWithNoTests)
|
|
12295
|
+
this.log(`No ${config.mode} files found, exiting with code 0
|
|
12296
|
+
`);
|
|
12297
|
+
else
|
|
12298
|
+
this.error(c.red(`
|
|
12563
12299
|
No ${config.mode} files found, exiting with code 1`));
|
|
12300
|
+
}
|
|
12564
12301
|
}
|
|
12565
12302
|
printBanner() {
|
|
12566
12303
|
var _a, _b;
|
|
@@ -12595,7 +12332,7 @@ This might cause false positive tests. Resolve unhandled errors to make sure you
|
|
|
12595
12332
|
this.log(c.red(divider(c.bold(c.inverse(" Unhandled Errors ")))));
|
|
12596
12333
|
this.log(errorMessage);
|
|
12597
12334
|
await Promise.all(errors.map(async (err) => {
|
|
12598
|
-
await this.printError(err, true, err.type || "Unhandled Error");
|
|
12335
|
+
await this.printError(err, { fullStack: true, type: err.type || "Unhandled Error" });
|
|
12599
12336
|
}));
|
|
12600
12337
|
this.log(c.red(divider()));
|
|
12601
12338
|
}
|
|
@@ -12607,7 +12344,7 @@ Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related t
|
|
|
12607
12344
|
this.log(c.red(divider(c.bold(c.inverse(" Source Errors ")))));
|
|
12608
12345
|
this.log(errorMessage);
|
|
12609
12346
|
await Promise.all(errors.map(async (err) => {
|
|
12610
|
-
await this.printError(err, true);
|
|
12347
|
+
await this.printError(err, { fullStack: true });
|
|
12611
12348
|
}));
|
|
12612
12349
|
this.log(c.red(divider()));
|
|
12613
12350
|
}
|
|
@@ -12766,7 +12503,7 @@ function MocksPlugin() {
|
|
|
12766
12503
|
async function createBrowserServer(project, options) {
|
|
12767
12504
|
const root = project.config.root;
|
|
12768
12505
|
await ensurePackageInstalled("@vitest/browser", root);
|
|
12769
|
-
const configPath = options.config === false ? false : options.config ? resolve
|
|
12506
|
+
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
12770
12507
|
const server = await createServer({
|
|
12771
12508
|
logLevel: "error",
|
|
12772
12509
|
mode: project.config.mode,
|
|
@@ -12804,7 +12541,7 @@ async function createBrowserServer(project, options) {
|
|
|
12804
12541
|
});
|
|
12805
12542
|
await server.listen();
|
|
12806
12543
|
await server.watcher.close();
|
|
12807
|
-
(await import('./chunk-api-setup.
|
|
12544
|
+
(await import('./chunk-api-setup.644415c3.js')).setup(project, server);
|
|
12808
12545
|
return server;
|
|
12809
12546
|
}
|
|
12810
12547
|
|
|
@@ -13007,21 +12744,29 @@ function CSSEnablerPlugin(ctx) {
|
|
|
13007
12744
|
];
|
|
13008
12745
|
}
|
|
13009
12746
|
|
|
13010
|
-
function
|
|
12747
|
+
function SsrReplacerPlugin() {
|
|
13011
12748
|
return {
|
|
13012
12749
|
name: "vitest:env-replacer",
|
|
13013
12750
|
enforce: "pre",
|
|
13014
12751
|
transform(code, id) {
|
|
13015
|
-
if (!/\bimport\.meta\.env\b
|
|
12752
|
+
if (!/\bimport\.meta\.env\b/.test(code) && !/\bimport\.meta\.url\b/.test(code))
|
|
13016
12753
|
return null;
|
|
13017
12754
|
let s = null;
|
|
13018
|
-
const
|
|
12755
|
+
const cleanCode = stripLiteral(code);
|
|
12756
|
+
const envs = cleanCode.matchAll(/\bimport\.meta\.env\b/g);
|
|
13019
12757
|
for (const env of envs) {
|
|
13020
12758
|
s || (s = new MagicString(code));
|
|
13021
12759
|
const startIndex = env.index;
|
|
13022
12760
|
const endIndex = startIndex + env[0].length;
|
|
13023
12761
|
s.overwrite(startIndex, endIndex, "process.env");
|
|
13024
12762
|
}
|
|
12763
|
+
const urls = cleanCode.matchAll(/\bimport\.meta\.url\b/g);
|
|
12764
|
+
for (const env of urls) {
|
|
12765
|
+
s || (s = new MagicString(code));
|
|
12766
|
+
const startIndex = env.index;
|
|
12767
|
+
const endIndex = startIndex + env[0].length;
|
|
12768
|
+
s.overwrite(startIndex, endIndex, "__vite_ssr_import_meta__.url");
|
|
12769
|
+
}
|
|
13025
12770
|
if (s) {
|
|
13026
12771
|
return {
|
|
13027
12772
|
code: s.toString(),
|
|
@@ -13105,14 +12850,17 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
13105
12850
|
};
|
|
13106
12851
|
}
|
|
13107
12852
|
|
|
13108
|
-
function resolveOptimizerConfig(
|
|
12853
|
+
function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
13109
12854
|
var _a;
|
|
12855
|
+
const testOptions = _testOptions || {};
|
|
13110
12856
|
const newConfig = {};
|
|
13111
12857
|
const [major, minor] = version$2.split(".").map(Number);
|
|
13112
12858
|
const allowed = major >= 5 || major === 4 && minor >= 3;
|
|
13113
|
-
if (!allowed && (
|
|
12859
|
+
if (!allowed && (testOptions == null ? void 0 : testOptions.enabled) === true)
|
|
13114
12860
|
console.warn(`Vitest: "deps.optimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
|
|
13115
|
-
|
|
12861
|
+
else
|
|
12862
|
+
testOptions.enabled ?? (testOptions.enabled = true);
|
|
12863
|
+
if (!allowed || (testOptions == null ? void 0 : testOptions.enabled) !== true) {
|
|
13116
12864
|
newConfig.cacheDir = void 0;
|
|
13117
12865
|
newConfig.optimizeDeps = {
|
|
13118
12866
|
// experimental in Vite >2.9.2, entries remains to help with older versions
|
|
@@ -13124,12 +12872,12 @@ function resolveOptimizerConfig(testOptionc, viteOptions, testConfig) {
|
|
|
13124
12872
|
newConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
|
|
13125
12873
|
newConfig.optimizeDeps = {
|
|
13126
12874
|
...viteOptions,
|
|
13127
|
-
...
|
|
12875
|
+
...testOptions,
|
|
13128
12876
|
noDiscovery: true,
|
|
13129
12877
|
disabled: false,
|
|
13130
12878
|
entries: [],
|
|
13131
|
-
exclude: ["vitest", ...builtinModules, ...
|
|
13132
|
-
include: (
|
|
12879
|
+
exclude: ["vitest", ...builtinModules, ...testOptions.exclude || (viteOptions == null ? void 0 : viteOptions.exclude) || []],
|
|
12880
|
+
include: (testOptions.include || (viteOptions == null ? void 0 : viteOptions.include) || []).filter((n) => n !== "vitest")
|
|
13133
12881
|
};
|
|
13134
12882
|
}
|
|
13135
12883
|
return newConfig;
|
|
@@ -13247,8 +12995,8 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13247
12995
|
};
|
|
13248
12996
|
}
|
|
13249
12997
|
}
|
|
13250
|
-
const webOptimizer = resolveOptimizerConfig((_e = (_d = testConfig.deps) == null ? void 0 : _d.
|
|
13251
|
-
const ssrOptimizer = resolveOptimizerConfig((_g = (_f = testConfig.deps) == null ? void 0 : _f.
|
|
12998
|
+
const webOptimizer = resolveOptimizerConfig((_e = (_d = testConfig.deps) == null ? void 0 : _d.optimizer) == null ? void 0 : _e.web, viteConfig.optimizeDeps, testConfig);
|
|
12999
|
+
const ssrOptimizer = resolveOptimizerConfig((_g = (_f = testConfig.deps) == null ? void 0 : _f.optimizer) == null ? void 0 : _g.ssr, (_h = viteConfig.ssr) == null ? void 0 : _h.optimizeDeps, testConfig);
|
|
13252
13000
|
config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
|
|
13253
13001
|
config.optimizeDeps = webOptimizer.optimizeDeps;
|
|
13254
13002
|
config.ssr = {
|
|
@@ -13265,13 +13013,13 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13265
13013
|
);
|
|
13266
13014
|
await project.setServer(options2, server);
|
|
13267
13015
|
} catch (err) {
|
|
13268
|
-
await project.ctx.logger.printError(err, true);
|
|
13016
|
+
await project.ctx.logger.printError(err, { fullStack: true });
|
|
13269
13017
|
process.exit(1);
|
|
13270
13018
|
}
|
|
13271
13019
|
await server.watcher.close();
|
|
13272
13020
|
}
|
|
13273
13021
|
},
|
|
13274
|
-
|
|
13022
|
+
SsrReplacerPlugin(),
|
|
13275
13023
|
...CSSEnablerPlugin(project),
|
|
13276
13024
|
CoverageTransform(project.ctx),
|
|
13277
13025
|
GlobalSetupPlugin(project, project.ctx.logger),
|
|
@@ -13283,7 +13031,7 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13283
13031
|
async function initializeProject(workspacePath, ctx, options) {
|
|
13284
13032
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
13285
13033
|
const project = new WorkspaceProject(workspacePath, ctx);
|
|
13286
|
-
const configFile = options.extends ? resolve
|
|
13034
|
+
const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
13287
13035
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
|
|
13288
13036
|
const config = {
|
|
13289
13037
|
...options,
|
|
@@ -13298,7 +13046,7 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
13298
13046
|
]
|
|
13299
13047
|
};
|
|
13300
13048
|
const server = await createServer(config);
|
|
13301
|
-
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = project.config.deps) == null ? void 0 : _b.
|
|
13049
|
+
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = project.config.deps) == null ? void 0 : _b.optimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = project.config.deps) == null ? void 0 : _e.optimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
|
|
13302
13050
|
await server.listen();
|
|
13303
13051
|
else
|
|
13304
13052
|
await server.pluginContainer.buildStart({});
|
|
@@ -13314,16 +13062,30 @@ class WorkspaceProject {
|
|
|
13314
13062
|
server;
|
|
13315
13063
|
vitenode;
|
|
13316
13064
|
runner;
|
|
13317
|
-
browser
|
|
13065
|
+
browser;
|
|
13318
13066
|
typechecker;
|
|
13319
13067
|
closingPromise;
|
|
13320
13068
|
browserProvider;
|
|
13069
|
+
testFilesList = [];
|
|
13321
13070
|
getName() {
|
|
13322
13071
|
return this.config.name || "";
|
|
13323
13072
|
}
|
|
13324
13073
|
isCore() {
|
|
13325
13074
|
return this.ctx.getCoreWorkspaceProject() === this;
|
|
13326
13075
|
}
|
|
13076
|
+
getModuleById(id) {
|
|
13077
|
+
var _a;
|
|
13078
|
+
return this.server.moduleGraph.getModuleById(id) || ((_a = this.browser) == null ? void 0 : _a.moduleGraph.getModuleById(id));
|
|
13079
|
+
}
|
|
13080
|
+
getSourceMapModuleById(id) {
|
|
13081
|
+
var _a, _b;
|
|
13082
|
+
const mod = this.server.moduleGraph.getModuleById(id);
|
|
13083
|
+
return ((_a = mod == null ? void 0 : mod.ssrTransformResult) == null ? void 0 : _a.map) || ((_b = mod == null ? void 0 : mod.transformResult) == null ? void 0 : _b.map);
|
|
13084
|
+
}
|
|
13085
|
+
getBrowserSourceMapModuleById(id) {
|
|
13086
|
+
var _a, _b, _c;
|
|
13087
|
+
return (_c = (_b = (_a = this.browser) == null ? void 0 : _a.moduleGraph.getModuleById(id)) == null ? void 0 : _b.transformResult) == null ? void 0 : _c.map;
|
|
13088
|
+
}
|
|
13327
13089
|
get reporters() {
|
|
13328
13090
|
return this.ctx.reporters;
|
|
13329
13091
|
}
|
|
@@ -13347,8 +13109,12 @@ class WorkspaceProject {
|
|
|
13347
13109
|
}
|
|
13348
13110
|
}));
|
|
13349
13111
|
}
|
|
13112
|
+
this.testFilesList = testFiles;
|
|
13350
13113
|
return testFiles;
|
|
13351
13114
|
}
|
|
13115
|
+
isTestFile(id) {
|
|
13116
|
+
return this.testFilesList.includes(id);
|
|
13117
|
+
}
|
|
13352
13118
|
async globFiles(include, exclude, cwd) {
|
|
13353
13119
|
const globOptions = {
|
|
13354
13120
|
absolute: true,
|
|
@@ -13485,10 +13251,10 @@ class WorkspaceProject {
|
|
|
13485
13251
|
...this.config.deps,
|
|
13486
13252
|
optimizer: {
|
|
13487
13253
|
web: {
|
|
13488
|
-
enabled: ((_c = (_b = (_a = this.config.deps) == null ? void 0 : _a.
|
|
13254
|
+
enabled: ((_c = (_b = (_a = this.config.deps) == null ? void 0 : _a.optimizer) == null ? void 0 : _b.web) == null ? void 0 : _c.enabled) ?? false
|
|
13489
13255
|
},
|
|
13490
13256
|
ssr: {
|
|
13491
|
-
enabled: ((_f = (_e = (_d = this.config.deps) == null ? void 0 : _d.
|
|
13257
|
+
enabled: ((_f = (_e = (_d = this.config.deps) == null ? void 0 : _d.optimizer) == null ? void 0 : _e.ssr) == null ? void 0 : _f.enabled) ?? false
|
|
13492
13258
|
}
|
|
13493
13259
|
}
|
|
13494
13260
|
},
|
|
@@ -13590,7 +13356,7 @@ class Vitest {
|
|
|
13590
13356
|
this.snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
|
|
13591
13357
|
if (this.config.watch && this.mode !== "typecheck")
|
|
13592
13358
|
this.registerWatcher();
|
|
13593
|
-
this.vitenode = new ViteNodeServer(server, this.config);
|
|
13359
|
+
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
13594
13360
|
const node = this.vitenode;
|
|
13595
13361
|
this.runner = new ViteNodeRunner({
|
|
13596
13362
|
root: server.config.root,
|
|
@@ -13640,6 +13406,12 @@ class Vitest {
|
|
|
13640
13406
|
getCoreWorkspaceProject() {
|
|
13641
13407
|
return this.coreWorkspace || null;
|
|
13642
13408
|
}
|
|
13409
|
+
getProjectByTaskId(taskId) {
|
|
13410
|
+
var _a;
|
|
13411
|
+
const task = this.state.idMap.get(taskId);
|
|
13412
|
+
const projectName = task.projectName || ((_a = task == null ? void 0 : task.file) == null ? void 0 : _a.projectName);
|
|
13413
|
+
return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
|
|
13414
|
+
}
|
|
13643
13415
|
async resolveWorkspace(options, cliOptions) {
|
|
13644
13416
|
const configDir = this.server.config.configFile ? dirname(this.server.config.configFile) : this.config.root;
|
|
13645
13417
|
const rootFiles = await promises.readdir(configDir);
|
|
@@ -13739,7 +13511,7 @@ class Vitest {
|
|
|
13739
13511
|
return Promise.all(this.projects.map((project) => project.typecheck(filters)));
|
|
13740
13512
|
}
|
|
13741
13513
|
async start(filters) {
|
|
13742
|
-
var _a;
|
|
13514
|
+
var _a, _b;
|
|
13743
13515
|
if (this.mode === "typecheck") {
|
|
13744
13516
|
await this.typecheck(filters);
|
|
13745
13517
|
return;
|
|
@@ -13755,32 +13527,40 @@ class Vitest {
|
|
|
13755
13527
|
await this.globTestFiles(filters)
|
|
13756
13528
|
);
|
|
13757
13529
|
if (!files.length) {
|
|
13758
|
-
const exitCode = this.config.passWithNoTests ? 0 : 1;
|
|
13759
13530
|
await this.reportCoverage(true);
|
|
13760
13531
|
this.logger.printNoTestFound(filters);
|
|
13761
|
-
|
|
13532
|
+
if (!this.config.watch || !(this.config.changed || ((_b = this.config.related) == null ? void 0 : _b.length))) {
|
|
13533
|
+
const exitCode = this.config.passWithNoTests ? 0 : 1;
|
|
13534
|
+
process.exit(exitCode);
|
|
13535
|
+
}
|
|
13536
|
+
}
|
|
13537
|
+
this.config.changed = false;
|
|
13538
|
+
this.config.related = void 0;
|
|
13539
|
+
if (files.length) {
|
|
13540
|
+
await this.cache.stats.populateStats(this.config.root, files);
|
|
13541
|
+
await this.runFiles(files);
|
|
13762
13542
|
}
|
|
13763
|
-
await this.cache.stats.populateStats(this.config.root, files);
|
|
13764
|
-
await this.runFiles(files);
|
|
13765
13543
|
await this.reportCoverage(true);
|
|
13766
13544
|
if (this.config.watch)
|
|
13767
13545
|
await this.report("onWatcherStart");
|
|
13768
13546
|
}
|
|
13769
|
-
async getTestDependencies(filepath) {
|
|
13770
|
-
const deps = /* @__PURE__ */ new Set();
|
|
13547
|
+
async getTestDependencies(filepath, deps = /* @__PURE__ */ new Set()) {
|
|
13771
13548
|
const addImports = async ([project, filepath2]) => {
|
|
13772
|
-
|
|
13549
|
+
if (deps.has(filepath2))
|
|
13550
|
+
return;
|
|
13551
|
+
const mod = project.server.moduleGraph.getModuleById(filepath2);
|
|
13552
|
+
const transformed = (mod == null ? void 0 : mod.ssrTransformResult) || await project.vitenode.transformRequest(filepath2);
|
|
13773
13553
|
if (!transformed)
|
|
13774
13554
|
return;
|
|
13775
13555
|
const dependencies = [...transformed.deps || [], ...transformed.dynamicDeps || []];
|
|
13776
|
-
|
|
13556
|
+
await Promise.all(dependencies.map(async (dep) => {
|
|
13777
13557
|
const path = await this.server.pluginContainer.resolveId(dep, filepath2, { ssr: true });
|
|
13778
13558
|
const fsPath = path && !path.external && path.id.split("?")[0];
|
|
13779
13559
|
if (fsPath && !fsPath.includes("node_modules") && !deps.has(fsPath) && existsSync(fsPath)) {
|
|
13780
13560
|
deps.add(fsPath);
|
|
13781
13561
|
await addImports([project, fsPath]);
|
|
13782
13562
|
}
|
|
13783
|
-
}
|
|
13563
|
+
}));
|
|
13784
13564
|
};
|
|
13785
13565
|
await addImports(filepath);
|
|
13786
13566
|
return deps;
|
|
@@ -13804,7 +13584,7 @@ class Vitest {
|
|
|
13804
13584
|
const forceRerunTriggers = this.config.forceRerunTriggers;
|
|
13805
13585
|
if (forceRerunTriggers.length && mm(related, forceRerunTriggers).length)
|
|
13806
13586
|
return specs;
|
|
13807
|
-
if (!related.length)
|
|
13587
|
+
if (!this.config.watch && !related.length)
|
|
13808
13588
|
return [];
|
|
13809
13589
|
const testGraphs = await Promise.all(
|
|
13810
13590
|
specs.map(async (spec) => {
|
|
@@ -13940,8 +13720,7 @@ class Vitest {
|
|
|
13940
13720
|
}
|
|
13941
13721
|
getModuleProjects(id) {
|
|
13942
13722
|
return this.projects.filter((project) => {
|
|
13943
|
-
|
|
13944
|
-
return project.server.moduleGraph.getModuleById(id) || ((_a = project.browser) == null ? void 0 : _a.moduleGraph.getModuleById(id)) || ((_c = (_b = project.browser) == null ? void 0 : _b.moduleGraph.getModulesByFile(id)) == null ? void 0 : _c.size);
|
|
13723
|
+
return project.getModuleById(id);
|
|
13945
13724
|
});
|
|
13946
13725
|
}
|
|
13947
13726
|
unregisterWatcher = noop$1;
|
|
@@ -14008,13 +13787,14 @@ class Vitest {
|
|
|
14008
13787
|
return [];
|
|
14009
13788
|
if (mm.isMatch(id, this.config.forceRerunTriggers)) {
|
|
14010
13789
|
this.state.getFilepaths().forEach((file) => this.changedTests.add(file));
|
|
14011
|
-
return [];
|
|
13790
|
+
return [id];
|
|
14012
13791
|
}
|
|
14013
13792
|
const projects = this.getModuleProjects(id);
|
|
14014
13793
|
if (!projects.length)
|
|
14015
13794
|
return [];
|
|
14016
13795
|
const files = [];
|
|
14017
|
-
for (const
|
|
13796
|
+
for (const project of projects) {
|
|
13797
|
+
const { server, browser } = project;
|
|
14018
13798
|
const mod = server.moduleGraph.getModuleById(id) || (browser == null ? void 0 : browser.moduleGraph.getModuleById(id));
|
|
14019
13799
|
if (!mod) {
|
|
14020
13800
|
const mods = browser == null ? void 0 : browser.moduleGraph.getModulesByFile(id);
|
|
@@ -14031,7 +13811,7 @@ class Vitest {
|
|
|
14031
13811
|
}
|
|
14032
13812
|
id = normalizeRequestId(id, server.config.base);
|
|
14033
13813
|
this.invalidates.add(id);
|
|
14034
|
-
if (this.state.filesMap.has(id)) {
|
|
13814
|
+
if (this.state.filesMap.has(id) || project.isTestFile(id)) {
|
|
14035
13815
|
this.changedTests.add(id);
|
|
14036
13816
|
files.push(id);
|
|
14037
13817
|
continue;
|
|
@@ -14196,6 +13976,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14196
13976
|
preTransformRequests: false
|
|
14197
13977
|
}
|
|
14198
13978
|
};
|
|
13979
|
+
if (process.platform === "darwin" && process.env.VITE_TEST_WATCHER_DEBUG) {
|
|
13980
|
+
config.server.watch.useFsEvents = false;
|
|
13981
|
+
config.server.watch.usePolling = false;
|
|
13982
|
+
}
|
|
14199
13983
|
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_c = (_b = testConfig.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
|
|
14200
13984
|
if (classNameStrategy !== "scoped") {
|
|
14201
13985
|
config.css ?? (config.css = {});
|
|
@@ -14207,8 +13991,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14207
13991
|
};
|
|
14208
13992
|
}
|
|
14209
13993
|
}
|
|
14210
|
-
const webOptimizer = resolveOptimizerConfig((_f = (_e = testConfig.deps) == null ? void 0 : _e.
|
|
14211
|
-
const ssrOptimizer = resolveOptimizerConfig((_h = (_g = testConfig.deps) == null ? void 0 : _g.
|
|
13994
|
+
const webOptimizer = resolveOptimizerConfig((_f = (_e = testConfig.deps) == null ? void 0 : _e.optimizer) == null ? void 0 : _f.web, viteConfig.optimizeDeps, testConfig);
|
|
13995
|
+
const ssrOptimizer = resolveOptimizerConfig((_h = (_g = testConfig.deps) == null ? void 0 : _g.optimizer) == null ? void 0 : _h.ssr, (_i = viteConfig.ssr) == null ? void 0 : _i.optimizeDeps, testConfig);
|
|
14212
13996
|
config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
|
|
14213
13997
|
config.optimizeDeps = webOptimizer.optimizeDeps;
|
|
14214
13998
|
config.ssr = {
|
|
@@ -14245,19 +14029,24 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14245
14029
|
}
|
|
14246
14030
|
},
|
|
14247
14031
|
async configureServer(server) {
|
|
14032
|
+
if (options.watch && process.env.VITE_TEST_WATCHER_DEBUG) {
|
|
14033
|
+
server.watcher.on("ready", () => {
|
|
14034
|
+
console.log("[debug] watcher is ready");
|
|
14035
|
+
});
|
|
14036
|
+
}
|
|
14248
14037
|
try {
|
|
14249
14038
|
await ctx.setServer(options, server, userConfig);
|
|
14250
14039
|
if (options.api && options.watch)
|
|
14251
|
-
(await import('./chunk-api-setup.
|
|
14040
|
+
(await import('./chunk-api-setup.644415c3.js')).setup(ctx);
|
|
14252
14041
|
} catch (err) {
|
|
14253
|
-
await ctx.logger.printError(err, true);
|
|
14042
|
+
await ctx.logger.printError(err, { fullStack: true });
|
|
14254
14043
|
process.exit(1);
|
|
14255
14044
|
}
|
|
14256
14045
|
if (!options.watch)
|
|
14257
14046
|
await server.watcher.close();
|
|
14258
14047
|
}
|
|
14259
14048
|
},
|
|
14260
|
-
|
|
14049
|
+
SsrReplacerPlugin(),
|
|
14261
14050
|
GlobalSetupPlugin(ctx, ctx.logger),
|
|
14262
14051
|
...CSSEnablerPlugin(ctx),
|
|
14263
14052
|
CoverageTransform(ctx),
|
|
@@ -14270,8 +14059,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14270
14059
|
async function createVitest(mode, options, viteOverrides = {}) {
|
|
14271
14060
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
14272
14061
|
const ctx = new Vitest(mode);
|
|
14273
|
-
const root = resolve
|
|
14274
|
-
const configPath = options.config === false ? false : options.config ? resolve
|
|
14062
|
+
const root = resolve(options.root || process.cwd());
|
|
14063
|
+
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
14275
14064
|
const config = {
|
|
14276
14065
|
logLevel: "error",
|
|
14277
14066
|
configFile: configPath,
|
|
@@ -14280,7 +14069,7 @@ async function createVitest(mode, options, viteOverrides = {}) {
|
|
|
14280
14069
|
plugins: await VitestPlugin(options, ctx)
|
|
14281
14070
|
};
|
|
14282
14071
|
const server = await createServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
|
|
14283
|
-
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = ctx.config.deps) == null ? void 0 : _b.
|
|
14072
|
+
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = ctx.config.deps) == null ? void 0 : _b.optimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = ctx.config.deps) == null ? void 0 : _e.optimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
|
|
14284
14073
|
await server.listen();
|
|
14285
14074
|
else
|
|
14286
14075
|
await server.pluginContainer.buildStart({});
|
|
@@ -20674,13 +20463,13 @@ function registerConsoleShortcuts(ctx) {
|
|
|
20674
20463
|
}
|
|
20675
20464
|
|
|
20676
20465
|
async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
20677
|
-
var _a
|
|
20466
|
+
var _a;
|
|
20678
20467
|
process.env.TEST = "true";
|
|
20679
20468
|
process.env.VITEST = "true";
|
|
20680
20469
|
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
|
|
20681
20470
|
if (options.run)
|
|
20682
20471
|
options.watch = false;
|
|
20683
|
-
const root = resolve
|
|
20472
|
+
const root = resolve(options.root || process.cwd());
|
|
20684
20473
|
if (!await ensurePackageInstalled("vite", root)) {
|
|
20685
20474
|
process.exitCode = 1;
|
|
20686
20475
|
return;
|
|
@@ -20693,14 +20482,14 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
20693
20482
|
options.browser = { enabled: true, name: options.browser };
|
|
20694
20483
|
if (typeof options.browser === "object" && !("enabled" in options.browser))
|
|
20695
20484
|
options.browser.enabled = true;
|
|
20485
|
+
if ("threads" in options && options.experimentalVmThreads)
|
|
20486
|
+
throw new Error('Cannot use both "threads" (or "no-threads") and "experimentalVmThreads" at the same time.');
|
|
20696
20487
|
const ctx = await createVitest(mode, options, viteOverrides);
|
|
20697
20488
|
if (mode === "test" && ctx.config.coverage.enabled) {
|
|
20698
20489
|
const provider = ctx.config.coverage.provider || "v8";
|
|
20699
20490
|
const requiredPackages = CoverageProviderMap[provider];
|
|
20700
20491
|
if (requiredPackages) {
|
|
20701
|
-
|
|
20702
|
-
const isUsingDefaultProvider = ((_c = (_b = ctx.server.config.test) == null ? void 0 : _b.coverage) == null ? void 0 : _c.provider) === void 0 && ((_d = options.coverage) == null ? void 0 : _d.provider) === void 0;
|
|
20703
|
-
if (!await ensurePackageInstalled(requiredPackages, root, isUsingDefaultProvider ? defaultProviderInfo : void 0)) {
|
|
20492
|
+
if (!await ensurePackageInstalled(requiredPackages, root)) {
|
|
20704
20493
|
process.exitCode = 1;
|
|
20705
20494
|
return ctx;
|
|
20706
20495
|
}
|
|
@@ -20726,7 +20515,7 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
20726
20515
|
await ctx.start(cliFilters);
|
|
20727
20516
|
} catch (e) {
|
|
20728
20517
|
process.exitCode = 1;
|
|
20729
|
-
await ctx.logger.printError(e, true, "Unhandled Error");
|
|
20518
|
+
await ctx.logger.printError(e, { fullStack: true, type: "Unhandled Error" });
|
|
20730
20519
|
ctx.logger.error("\n\n");
|
|
20731
20520
|
return ctx;
|
|
20732
20521
|
}
|