vitest 3.1.1 → 3.1.3
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 -44
- package/dist/browser.d.ts +4 -3
- package/dist/browser.js +3 -3
- package/dist/chunks/{base.bV8rwssx.js → base.DslwPSCy.js} +3 -3
- package/dist/chunks/{benchmark.BKUatJGy.js → benchmark.BoF7jW0Q.js} +1 -1
- package/dist/chunks/{cac.DK21mt6F.js → cac.BN2e7cE1.js} +8 -8
- package/dist/chunks/{cli-api.bwYuoT4p.js → cli-api.Bti1vevt.js} +272 -3521
- package/dist/chunks/{config.d.DevWltVl.d.ts → config.d.UqE-KR0o.d.ts} +2 -2
- package/dist/chunks/{console.D6t261w0.js → console.K1NMVOSc.js} +1 -1
- package/dist/chunks/{coverage.SfnlalVs.js → coverage.87S59-Sl.js} +18 -16
- package/dist/chunks/{defaults.DmfNPoe5.js → defaults.DSxsTG0h.js} +1 -1
- package/dist/chunks/{environment.d.C8UItCbf.d.ts → environment.d.Dmw5ulng.d.ts} +5 -58
- package/dist/chunks/{execute.CwmnH2oH.js → execute.BpmIjFTD.js} +22 -12
- package/dist/chunks/{global.d.Cg2sEPIm.d.ts → global.d.CXRAxnWc.d.ts} +1 -1
- package/dist/chunks/{globals.DCbUWjip.js → globals.CZAEe_Gf.js} +5 -5
- package/dist/chunks/{index.BDobFbcz.js → index.B0uVAVvx.js} +3 -3
- package/dist/chunks/{index.68735LiX.js → index.CJ0plNrh.js} +37 -8
- package/dist/chunks/{index.VfYQ6MXY.js → index.Cu2UlluP.js} +4 -4
- package/dist/chunks/{index.CwHmn5H5.js → index.De2FqGmR.js} +33 -21
- package/dist/chunks/{node.IqGoMrm4.js → node.3xsWotC9.js} +1 -1
- package/dist/chunks/{reporters.d.CfRkRKN2.d.ts → reporters.d.DG9VKi4m.d.ts} +22 -9
- package/dist/chunks/{rpc.DGgL5dw7.js → rpc.D9_013TY.js} +2 -2
- package/dist/chunks/{run-once.I7PpBOk1.js → run-once.Dimr7O9f.js} +1 -1
- package/dist/chunks/{runBaseTests.CqmKSG99.js → runBaseTests.BV8m0B-u.js} +10 -10
- package/dist/chunks/{setup-common.DEGDGBiA.js → setup-common.AQcDs321.js} +2 -2
- package/dist/chunks/{typechecker.CG0zmr19.js → typechecker.DYQbn8uK.js} +2 -2
- package/dist/chunks/{utils.Lot3J_8U.js → utils.Cc45eY3L.js} +10 -4
- package/dist/chunks/{utils.CtocqOoE.js → utils.CgTj3MsC.js} +1 -1
- package/dist/chunks/{vi.B-PuvDzu.js → vi.ClIskdbk.js} +1 -1
- package/dist/chunks/{vite.d.4pkSbgmp.d.ts → vite.d.D3ndlJcw.d.ts} +1 -1
- package/dist/chunks/{vm.Lp7mPCVW.js → vm.CuLHT1BG.js} +17 -9
- package/dist/chunks/{worker.d.CSFlSYJg.d.ts → worker.d.C-KN07Ls.d.ts} +1 -1
- package/dist/chunks/{worker.d.C58isfFm.d.ts → worker.d.CHGSOG0s.d.ts} +21 -4
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -7
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +6 -4
- package/dist/coverage.js +4 -4
- package/dist/environments.d.ts +3 -2
- package/dist/execute.d.ts +4 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.js +5 -5
- package/dist/node.d.ts +10 -8
- package/dist/node.js +12 -11
- package/dist/reporters.d.ts +6 -4
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +6 -6
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +3 -3
- package/dist/workers/forks.js +3 -3
- package/dist/workers/runVmTests.js +9 -9
- package/dist/workers/threads.js +3 -3
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +7 -7
- package/globals.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +17 -17
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { promises, existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import { extname, normalize, relative, dirname, resolve, join, basename, isAbsolute } from 'pathe';
|
|
3
3
|
import { C as CoverageProviderMap } from './coverage.0iPg4Wrz.js';
|
|
4
4
|
import p, { resolve as resolve$1 } from 'node:path';
|
|
5
5
|
import { noop, isPrimitive, createDefer, highlight, toArray, deepMerge, nanoid, slash, deepClone, notNullish } from '@vitest/utils';
|
|
6
6
|
import { f as findUp, p as prompt } from './index.DBIGubLC.js';
|
|
7
7
|
import * as vite from 'vite';
|
|
8
|
-
import { searchForWorkspaceRoot, version,
|
|
8
|
+
import { searchForWorkspaceRoot, version, mergeConfig, createServer } from 'vite';
|
|
9
9
|
import { A as API_PATH, c as configFiles, d as defaultBrowserPort, w as workspacesFiles, a as defaultPort } from './constants.BZZyIeIE.js';
|
|
10
10
|
import { generateFileHash, createFileTask, limitConcurrency, hasFailed, getTasks, getTests } from '@vitest/runner/utils';
|
|
11
11
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
12
12
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
13
13
|
import { ViteNodeServer } from 'vite-node/server';
|
|
14
|
-
import { v as version$1 } from './cac.
|
|
15
|
-
import { c as createBirpc } from './index.
|
|
16
|
-
import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.
|
|
14
|
+
import { v as version$1 } from './cac.BN2e7cE1.js';
|
|
15
|
+
import { c as createBirpc } from './index.CJ0plNrh.js';
|
|
16
|
+
import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.De2FqGmR.js';
|
|
17
17
|
import require$$0$3 from 'events';
|
|
18
18
|
import require$$1$1 from 'https';
|
|
19
19
|
import require$$2 from 'http';
|
|
@@ -28,21 +28,20 @@ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
|
28
28
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
29
29
|
import crypto from 'node:crypto';
|
|
30
30
|
import { distDir, rootDir } from '../path.js';
|
|
31
|
-
import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, g as getFilePoolName, d as isBrowserEnabled, m as mm, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.
|
|
32
|
-
import { c as convertTasksToEvents } from './typechecker.
|
|
31
|
+
import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, g as getFilePoolName, d as isBrowserEnabled, m as mm, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.87S59-Sl.js';
|
|
32
|
+
import { c as convertTasksToEvents } from './typechecker.DYQbn8uK.js';
|
|
33
33
|
import { Console } from 'node:console';
|
|
34
34
|
import c from 'tinyrainbow';
|
|
35
|
-
import { c as formatProjectName, w as withLabel, d as divider } from './utils.
|
|
35
|
+
import { c as formatProjectName, w as withLabel, e as errorBanner, d as divider } from './utils.Cc45eY3L.js';
|
|
36
36
|
import { createRequire } from 'node:module';
|
|
37
37
|
import url from 'node:url';
|
|
38
38
|
import { i as isTTY, a as isWindows } from './env.Dq0hM4Xv.js';
|
|
39
39
|
import { rm } from 'node:fs/promises';
|
|
40
40
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
41
|
-
import
|
|
42
|
-
import require$$0$5 from 'fs';
|
|
41
|
+
import { glob, isDynamicPattern } from 'tinyglobby';
|
|
43
42
|
import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
44
43
|
import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
|
|
45
|
-
import { c as configDefaults } from './defaults.
|
|
44
|
+
import { c as configDefaults } from './defaults.DSxsTG0h.js';
|
|
46
45
|
import MagicString from 'magic-string';
|
|
47
46
|
import assert$1 from 'node:assert';
|
|
48
47
|
import { serializeError } from '@vitest/utils/error';
|
|
@@ -51,19 +50,19 @@ import { stripVTControlCharacters } from 'node:util';
|
|
|
51
50
|
|
|
52
51
|
var bufferUtil = {exports: {}};
|
|
53
52
|
|
|
54
|
-
var constants
|
|
55
|
-
var hasRequiredConstants
|
|
53
|
+
var constants;
|
|
54
|
+
var hasRequiredConstants;
|
|
56
55
|
|
|
57
|
-
function requireConstants
|
|
58
|
-
if (hasRequiredConstants
|
|
59
|
-
hasRequiredConstants
|
|
56
|
+
function requireConstants () {
|
|
57
|
+
if (hasRequiredConstants) return constants;
|
|
58
|
+
hasRequiredConstants = 1;
|
|
60
59
|
|
|
61
60
|
const BINARY_TYPES = ['nodebuffer', 'arraybuffer', 'fragments'];
|
|
62
61
|
const hasBlob = typeof Blob !== 'undefined';
|
|
63
62
|
|
|
64
63
|
if (hasBlob) BINARY_TYPES.push('blob');
|
|
65
64
|
|
|
66
|
-
constants
|
|
65
|
+
constants = {
|
|
67
66
|
BINARY_TYPES,
|
|
68
67
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
69
68
|
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
|
@@ -74,7 +73,7 @@ function requireConstants$1 () {
|
|
|
74
73
|
kWebSocket: Symbol('websocket'),
|
|
75
74
|
NOOP: () => {}
|
|
76
75
|
};
|
|
77
|
-
return constants
|
|
76
|
+
return constants;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
var hasRequiredBufferUtil;
|
|
@@ -83,7 +82,7 @@ function requireBufferUtil () {
|
|
|
83
82
|
if (hasRequiredBufferUtil) return bufferUtil.exports;
|
|
84
83
|
hasRequiredBufferUtil = 1;
|
|
85
84
|
|
|
86
|
-
const { EMPTY_BUFFER } = requireConstants
|
|
85
|
+
const { EMPTY_BUFFER } = requireConstants();
|
|
87
86
|
|
|
88
87
|
const FastBuffer = Buffer[Symbol.species];
|
|
89
88
|
|
|
@@ -289,7 +288,7 @@ function requirePermessageDeflate () {
|
|
|
289
288
|
|
|
290
289
|
const bufferUtil = requireBufferUtil();
|
|
291
290
|
const Limiter = requireLimiter();
|
|
292
|
-
const { kStatusCode } = requireConstants
|
|
291
|
+
const { kStatusCode } = requireConstants();
|
|
293
292
|
|
|
294
293
|
const FastBuffer = Buffer[Symbol.species];
|
|
295
294
|
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
@@ -810,7 +809,7 @@ function requireValidation () {
|
|
|
810
809
|
|
|
811
810
|
const { isUtf8 } = require$$0$1;
|
|
812
811
|
|
|
813
|
-
const { hasBlob } = requireConstants
|
|
812
|
+
const { hasBlob } = requireConstants();
|
|
814
813
|
|
|
815
814
|
//
|
|
816
815
|
// Allowed token characters:
|
|
@@ -976,7 +975,7 @@ function requireReceiver () {
|
|
|
976
975
|
EMPTY_BUFFER,
|
|
977
976
|
kStatusCode,
|
|
978
977
|
kWebSocket
|
|
979
|
-
} = requireConstants
|
|
978
|
+
} = requireConstants();
|
|
980
979
|
const { concat, toArrayBuffer, unmask } = requireBufferUtil();
|
|
981
980
|
const { isValidStatusCode, isValidUTF8 } = requireValidation();
|
|
982
981
|
|
|
@@ -1688,7 +1687,7 @@ function requireSender () {
|
|
|
1688
1687
|
const { randomFillSync } = require$$1;
|
|
1689
1688
|
|
|
1690
1689
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
1691
|
-
const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants
|
|
1690
|
+
const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants();
|
|
1692
1691
|
const { isBlob, isValidStatusCode } = requireValidation();
|
|
1693
1692
|
const { mask: applyMask, toBuffer } = requireBufferUtil();
|
|
1694
1693
|
|
|
@@ -2292,7 +2291,7 @@ function requireEventTarget () {
|
|
|
2292
2291
|
if (hasRequiredEventTarget) return eventTarget;
|
|
2293
2292
|
hasRequiredEventTarget = 1;
|
|
2294
2293
|
|
|
2295
|
-
const { kForOnEventAttribute, kListener } = requireConstants
|
|
2294
|
+
const { kForOnEventAttribute, kListener } = requireConstants();
|
|
2296
2295
|
|
|
2297
2296
|
const kCode = Symbol('kCode');
|
|
2298
2297
|
const kData = Symbol('kData');
|
|
@@ -2828,7 +2827,7 @@ function requireWebsocket () {
|
|
|
2828
2827
|
kStatusCode,
|
|
2829
2828
|
kWebSocket,
|
|
2830
2829
|
NOOP
|
|
2831
|
-
} = requireConstants
|
|
2830
|
+
} = requireConstants();
|
|
2832
2831
|
const {
|
|
2833
2832
|
EventTarget: { addEventListener, removeEventListener }
|
|
2834
2833
|
} = requireEventTarget();
|
|
@@ -4458,7 +4457,7 @@ function requireWebsocketServer () {
|
|
|
4458
4457
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
4459
4458
|
const subprotocol = requireSubprotocol();
|
|
4460
4459
|
const WebSocket = requireWebsocket();
|
|
4461
|
-
const { GUID, kWebSocket } = requireConstants
|
|
4460
|
+
const { GUID, kWebSocket } = requireConstants();
|
|
4462
4461
|
|
|
4463
4462
|
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
4464
4463
|
|
|
@@ -5253,28 +5252,29 @@ var setup$1 = /*#__PURE__*/Object.freeze({
|
|
|
5253
5252
|
|
|
5254
5253
|
class BrowserSessions {
|
|
5255
5254
|
sessions = new Map();
|
|
5255
|
+
sessionIds = new Set();
|
|
5256
5256
|
getSession(sessionId) {
|
|
5257
5257
|
return this.sessions.get(sessionId);
|
|
5258
5258
|
}
|
|
5259
|
-
|
|
5259
|
+
destroySession(sessionId) {
|
|
5260
|
+
this.sessions.delete(sessionId);
|
|
5261
|
+
}
|
|
5262
|
+
createSession(sessionId, project, pool) {
|
|
5260
5263
|
const defer = createDefer();
|
|
5261
5264
|
const timeout = setTimeout(() => {
|
|
5262
|
-
|
|
5263
|
-
defer.reject(new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] for "${tests}" within the timeout.`));
|
|
5265
|
+
defer.reject(new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] within the timeout.`));
|
|
5264
5266
|
}, project.vitest.config.browser.connectTimeout ?? 6e4).unref();
|
|
5265
5267
|
this.sessions.set(sessionId, {
|
|
5266
|
-
files,
|
|
5267
|
-
method,
|
|
5268
5268
|
project,
|
|
5269
5269
|
connected: () => {
|
|
5270
|
+
defer.resolve();
|
|
5270
5271
|
clearTimeout(timeout);
|
|
5271
5272
|
},
|
|
5272
|
-
|
|
5273
|
+
fail: (error) => {
|
|
5273
5274
|
defer.resolve();
|
|
5274
5275
|
clearTimeout(timeout);
|
|
5275
|
-
|
|
5276
|
-
}
|
|
5277
|
-
reject: defer.reject
|
|
5276
|
+
pool.reject(error);
|
|
5277
|
+
}
|
|
5278
5278
|
});
|
|
5279
5279
|
return defer;
|
|
5280
5280
|
}
|
|
@@ -5508,7 +5508,7 @@ class Logger {
|
|
|
5508
5508
|
}
|
|
5509
5509
|
printUnhandledErrors(errors) {
|
|
5510
5510
|
const errorMessage = c.red(c.bold(`\nVitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.` + "\nThis might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected."));
|
|
5511
|
-
this.error(
|
|
5511
|
+
this.error(errorBanner("Unhandled Errors"));
|
|
5512
5512
|
this.error(errorMessage);
|
|
5513
5513
|
errors.forEach((err) => {
|
|
5514
5514
|
this.printError(err, {
|
|
@@ -5520,7 +5520,7 @@ class Logger {
|
|
|
5520
5520
|
}
|
|
5521
5521
|
printSourceTypeErrors(errors) {
|
|
5522
5522
|
const errorMessage = c.red(c.bold(`\nVitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`));
|
|
5523
|
-
this.log(
|
|
5523
|
+
this.log(errorBanner("Source Errors"));
|
|
5524
5524
|
this.log(errorMessage);
|
|
5525
5525
|
errors.forEach((err) => {
|
|
5526
5526
|
this.printError(err, { fullStack: true });
|
|
@@ -5614,3479 +5614,201 @@ class VitestPackageInstaller {
|
|
|
5614
5614
|
}
|
|
5615
5615
|
}
|
|
5616
5616
|
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5617
|
+
function serializeConfig(config, coreConfig, viteConfig) {
|
|
5618
|
+
const optimizer = config.deps?.optimizer;
|
|
5619
|
+
const poolOptions = config.poolOptions;
|
|
5620
|
+
const isolate = viteConfig?.test?.isolate;
|
|
5621
|
+
return {
|
|
5622
|
+
environmentOptions: config.environmentOptions,
|
|
5623
|
+
mode: config.mode,
|
|
5624
|
+
isolate: config.isolate,
|
|
5625
|
+
base: config.base,
|
|
5626
|
+
logHeapUsage: config.logHeapUsage,
|
|
5627
|
+
runner: config.runner,
|
|
5628
|
+
bail: config.bail,
|
|
5629
|
+
defines: config.defines,
|
|
5630
|
+
chaiConfig: config.chaiConfig,
|
|
5631
|
+
setupFiles: config.setupFiles,
|
|
5632
|
+
allowOnly: config.allowOnly,
|
|
5633
|
+
testTimeout: config.testTimeout,
|
|
5634
|
+
testNamePattern: config.testNamePattern,
|
|
5635
|
+
hookTimeout: config.hookTimeout,
|
|
5636
|
+
clearMocks: config.clearMocks,
|
|
5637
|
+
mockReset: config.mockReset,
|
|
5638
|
+
restoreMocks: config.restoreMocks,
|
|
5639
|
+
unstubEnvs: config.unstubEnvs,
|
|
5640
|
+
unstubGlobals: config.unstubGlobals,
|
|
5641
|
+
maxConcurrency: config.maxConcurrency,
|
|
5642
|
+
pool: config.pool,
|
|
5643
|
+
expect: config.expect,
|
|
5644
|
+
snapshotSerializers: config.snapshotSerializers,
|
|
5645
|
+
diff: config.diff,
|
|
5646
|
+
retry: config.retry,
|
|
5647
|
+
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
5648
|
+
root: config.root,
|
|
5649
|
+
name: config.name,
|
|
5650
|
+
globals: config.globals,
|
|
5651
|
+
snapshotEnvironment: config.snapshotEnvironment,
|
|
5652
|
+
passWithNoTests: config.passWithNoTests,
|
|
5653
|
+
coverage: ((coverage) => {
|
|
5654
|
+
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
5655
|
+
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
5656
|
+
return {
|
|
5657
|
+
reportsDirectory: coverage.reportsDirectory,
|
|
5658
|
+
provider: coverage.provider,
|
|
5659
|
+
enabled: coverage.enabled,
|
|
5660
|
+
htmlReporter: htmlReporter ? { subdir } : undefined,
|
|
5661
|
+
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : undefined
|
|
5662
|
+
};
|
|
5663
|
+
})(config.coverage),
|
|
5664
|
+
fakeTimers: config.fakeTimers,
|
|
5665
|
+
poolOptions: {
|
|
5666
|
+
forks: {
|
|
5667
|
+
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
5668
|
+
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
5669
|
+
},
|
|
5670
|
+
threads: {
|
|
5671
|
+
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
5672
|
+
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
5673
|
+
},
|
|
5674
|
+
vmThreads: { singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false },
|
|
5675
|
+
vmForks: { singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false }
|
|
5676
|
+
},
|
|
5677
|
+
deps: {
|
|
5678
|
+
web: config.deps.web || {},
|
|
5679
|
+
optimizer: {
|
|
5680
|
+
web: { enabled: optimizer?.web?.enabled ?? true },
|
|
5681
|
+
ssr: { enabled: optimizer?.ssr?.enabled ?? true }
|
|
5682
|
+
},
|
|
5683
|
+
interopDefault: config.deps.interopDefault,
|
|
5684
|
+
moduleDirectories: config.deps.moduleDirectories
|
|
5685
|
+
},
|
|
5686
|
+
snapshotOptions: {
|
|
5687
|
+
snapshotEnvironment: undefined,
|
|
5688
|
+
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
5689
|
+
snapshotFormat: {
|
|
5690
|
+
...coreConfig.snapshotOptions.snapshotFormat,
|
|
5691
|
+
compareKeys: undefined
|
|
5692
|
+
},
|
|
5693
|
+
expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
|
|
5694
|
+
},
|
|
5695
|
+
sequence: {
|
|
5696
|
+
shuffle: coreConfig.sequence.shuffle,
|
|
5697
|
+
concurrent: coreConfig.sequence.concurrent,
|
|
5698
|
+
seed: coreConfig.sequence.seed,
|
|
5699
|
+
hooks: coreConfig.sequence.hooks,
|
|
5700
|
+
setupFiles: coreConfig.sequence.setupFiles
|
|
5701
|
+
},
|
|
5702
|
+
inspect: coreConfig.inspect,
|
|
5703
|
+
inspectBrk: coreConfig.inspectBrk,
|
|
5704
|
+
inspector: coreConfig.inspector,
|
|
5705
|
+
watch: config.watch,
|
|
5706
|
+
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
5707
|
+
env: {
|
|
5708
|
+
...viteConfig?.env,
|
|
5709
|
+
...config.env
|
|
5710
|
+
},
|
|
5711
|
+
browser: ((browser) => {
|
|
5712
|
+
return {
|
|
5713
|
+
name: browser.name,
|
|
5714
|
+
headless: browser.headless,
|
|
5715
|
+
isolate: browser.isolate,
|
|
5716
|
+
fileParallelism: browser.fileParallelism,
|
|
5717
|
+
ui: browser.ui,
|
|
5718
|
+
viewport: browser.viewport,
|
|
5719
|
+
screenshotFailures: browser.screenshotFailures,
|
|
5720
|
+
locators: { testIdAttribute: browser.locators.testIdAttribute },
|
|
5721
|
+
providerOptions: browser.provider === "playwright" ? { actionTimeout: browser.providerOptions?.context?.actionTimeout } : {}
|
|
5722
|
+
};
|
|
5723
|
+
})(config.browser),
|
|
5724
|
+
standalone: config.standalone,
|
|
5725
|
+
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace,
|
|
5726
|
+
benchmark: config.benchmark && { includeSamples: config.benchmark.includeSamples }
|
|
5727
|
+
};
|
|
5666
5728
|
}
|
|
5667
5729
|
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
function requireJoinPath () {
|
|
5673
|
-
if (hasRequiredJoinPath) return joinPath;
|
|
5674
|
-
hasRequiredJoinPath = 1;
|
|
5675
|
-
Object.defineProperty(joinPath, "__esModule", { value: true });
|
|
5676
|
-
joinPath.build = joinPath.joinDirectoryPath = joinPath.joinPathWithBasePath = void 0;
|
|
5677
|
-
const path_1 = require$$0$4;
|
|
5678
|
-
const utils_1 = requireUtils$1();
|
|
5679
|
-
function joinPathWithBasePath(filename, directoryPath) {
|
|
5680
|
-
return directoryPath + filename;
|
|
5681
|
-
}
|
|
5682
|
-
joinPath.joinPathWithBasePath = joinPathWithBasePath;
|
|
5683
|
-
function joinPathWithRelativePath(root, options) {
|
|
5684
|
-
return function (filename, directoryPath) {
|
|
5685
|
-
const sameRoot = directoryPath.startsWith(root);
|
|
5686
|
-
if (sameRoot)
|
|
5687
|
-
return directoryPath.replace(root, "") + filename;
|
|
5688
|
-
else
|
|
5689
|
-
return ((0, utils_1.convertSlashes)((0, path_1.relative)(root, directoryPath), options.pathSeparator) +
|
|
5690
|
-
options.pathSeparator +
|
|
5691
|
-
filename);
|
|
5692
|
-
};
|
|
5693
|
-
}
|
|
5694
|
-
function joinPath$1(filename) {
|
|
5695
|
-
return filename;
|
|
5696
|
-
}
|
|
5697
|
-
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
5698
|
-
return directoryPath + filename + separator;
|
|
5699
|
-
}
|
|
5700
|
-
joinPath.joinDirectoryPath = joinDirectoryPath;
|
|
5701
|
-
function build(root, options) {
|
|
5702
|
-
const { relativePaths, includeBasePath } = options;
|
|
5703
|
-
return relativePaths && root
|
|
5704
|
-
? joinPathWithRelativePath(root, options)
|
|
5705
|
-
: includeBasePath
|
|
5706
|
-
? joinPathWithBasePath
|
|
5707
|
-
: joinPath$1;
|
|
5708
|
-
}
|
|
5709
|
-
joinPath.build = build;
|
|
5710
|
-
return joinPath;
|
|
5730
|
+
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
5731
|
+
const globalSetupFiles = toArray(globalSetup);
|
|
5732
|
+
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
|
|
5711
5733
|
}
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
function pushDirectoryWithRelativePath(root) {
|
|
5723
|
-
return function (directoryPath, paths) {
|
|
5724
|
-
paths.push(directoryPath.substring(root.length) || ".");
|
|
5725
|
-
};
|
|
5734
|
+
async function loadGlobalSetupFile(file, runner) {
|
|
5735
|
+
const m = await runner.executeFile(file);
|
|
5736
|
+
for (const exp of [
|
|
5737
|
+
"default",
|
|
5738
|
+
"setup",
|
|
5739
|
+
"teardown"
|
|
5740
|
+
]) {
|
|
5741
|
+
if (m[exp] != null && typeof m[exp] !== "function") {
|
|
5742
|
+
throw new Error(`invalid export in globalSetup file ${file}: ${exp} must be a function`);
|
|
5743
|
+
}
|
|
5726
5744
|
}
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5745
|
+
if (m.default) {
|
|
5746
|
+
return {
|
|
5747
|
+
file,
|
|
5748
|
+
setup: m.default
|
|
5749
|
+
};
|
|
5750
|
+
} else if (m.setup || m.teardown) {
|
|
5751
|
+
return {
|
|
5752
|
+
file,
|
|
5753
|
+
setup: m.setup,
|
|
5754
|
+
teardown: m.teardown
|
|
5755
|
+
};
|
|
5756
|
+
} else {
|
|
5757
|
+
throw new Error(`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`);
|
|
5734
5758
|
}
|
|
5735
|
-
const pushDirectory$1 = (directoryPath, paths) => {
|
|
5736
|
-
paths.push(directoryPath || ".");
|
|
5737
|
-
};
|
|
5738
|
-
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
5739
|
-
const path = directoryPath || ".";
|
|
5740
|
-
if (filters.every((filter) => filter(path, true))) {
|
|
5741
|
-
paths.push(path);
|
|
5742
|
-
}
|
|
5743
|
-
};
|
|
5744
|
-
const empty = () => { };
|
|
5745
|
-
function build(root, options) {
|
|
5746
|
-
const { includeDirs, filters, relativePaths } = options;
|
|
5747
|
-
if (!includeDirs)
|
|
5748
|
-
return empty;
|
|
5749
|
-
if (relativePaths)
|
|
5750
|
-
return filters && filters.length
|
|
5751
|
-
? pushDirectoryFilterWithRelativePath(root)
|
|
5752
|
-
: pushDirectoryWithRelativePath(root);
|
|
5753
|
-
return filters && filters.length ? pushDirectoryFilter : pushDirectory$1;
|
|
5754
|
-
}
|
|
5755
|
-
pushDirectory.build = build;
|
|
5756
|
-
return pushDirectory;
|
|
5757
5759
|
}
|
|
5758
5760
|
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
hasRequiredPushFile = 1;
|
|
5766
|
-
Object.defineProperty(pushFile, "__esModule", { value: true });
|
|
5767
|
-
pushFile.build = void 0;
|
|
5768
|
-
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
5769
|
-
if (filters.every((filter) => filter(filename, false)))
|
|
5770
|
-
counts.files++;
|
|
5771
|
-
};
|
|
5772
|
-
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
5773
|
-
if (filters.every((filter) => filter(filename, false)))
|
|
5774
|
-
paths.push(filename);
|
|
5775
|
-
};
|
|
5776
|
-
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
5777
|
-
counts.files++;
|
|
5778
|
-
};
|
|
5779
|
-
const pushFile$1 = (filename, paths) => {
|
|
5780
|
-
paths.push(filename);
|
|
5761
|
+
function CoverageTransform(ctx) {
|
|
5762
|
+
return {
|
|
5763
|
+
name: "vitest:coverage-transform",
|
|
5764
|
+
transform(srcCode, id) {
|
|
5765
|
+
return ctx.coverageProvider?.onFileTransform?.(srcCode, normalizeRequestId(id), this);
|
|
5766
|
+
}
|
|
5781
5767
|
};
|
|
5782
|
-
const empty = () => { };
|
|
5783
|
-
function build(options) {
|
|
5784
|
-
const { excludeFiles, filters, onlyCounts } = options;
|
|
5785
|
-
if (excludeFiles)
|
|
5786
|
-
return empty;
|
|
5787
|
-
if (filters && filters.length) {
|
|
5788
|
-
return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
5789
|
-
}
|
|
5790
|
-
else if (onlyCounts) {
|
|
5791
|
-
return pushFileCount;
|
|
5792
|
-
}
|
|
5793
|
-
else {
|
|
5794
|
-
return pushFile$1;
|
|
5795
|
-
}
|
|
5796
|
-
}
|
|
5797
|
-
pushFile.build = build;
|
|
5798
|
-
return pushFile;
|
|
5799
5768
|
}
|
|
5800
5769
|
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
return options.group ? getArrayGroup : getArray$1;
|
|
5818
|
-
}
|
|
5819
|
-
getArray.build = build;
|
|
5820
|
-
return getArray;
|
|
5770
|
+
function MocksPlugins(options = {}) {
|
|
5771
|
+
const normalizedDistDir = normalize(distDir);
|
|
5772
|
+
return [hoistMocksPlugin({
|
|
5773
|
+
filter(id) {
|
|
5774
|
+
if (id.includes(normalizedDistDir)) {
|
|
5775
|
+
return false;
|
|
5776
|
+
}
|
|
5777
|
+
if (options.filter) {
|
|
5778
|
+
return options.filter(id);
|
|
5779
|
+
}
|
|
5780
|
+
return true;
|
|
5781
|
+
},
|
|
5782
|
+
codeFrameGenerator(node, id, code) {
|
|
5783
|
+
return generateCodeFrame(code, 4, node.start + 1);
|
|
5784
|
+
}
|
|
5785
|
+
}), automockPlugin()];
|
|
5821
5786
|
}
|
|
5822
5787
|
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
var hasRequiredGroupFiles;
|
|
5826
|
-
|
|
5827
|
-
function requireGroupFiles () {
|
|
5828
|
-
if (hasRequiredGroupFiles) return groupFiles;
|
|
5829
|
-
hasRequiredGroupFiles = 1;
|
|
5830
|
-
Object.defineProperty(groupFiles, "__esModule", { value: true });
|
|
5831
|
-
groupFiles.build = void 0;
|
|
5832
|
-
const groupFiles$1 = (groups, directory, files) => {
|
|
5833
|
-
groups.push({ directory, files, dir: directory });
|
|
5834
|
-
};
|
|
5835
|
-
const empty = () => { };
|
|
5836
|
-
function build(options) {
|
|
5837
|
-
return options.group ? groupFiles$1 : empty;
|
|
5838
|
-
}
|
|
5839
|
-
groupFiles.build = build;
|
|
5840
|
-
return groupFiles;
|
|
5788
|
+
function generateCssFilenameHash(filepath) {
|
|
5789
|
+
return hash("md5", filepath, "hex").slice(0, 6);
|
|
5841
5790
|
}
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
var hasRequiredResolveSymlink;
|
|
5846
|
-
|
|
5847
|
-
function requireResolveSymlink () {
|
|
5848
|
-
if (hasRequiredResolveSymlink) return resolveSymlink;
|
|
5849
|
-
hasRequiredResolveSymlink = 1;
|
|
5850
|
-
var __importDefault = (resolveSymlink && resolveSymlink.__importDefault) || function (mod) {
|
|
5851
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5852
|
-
};
|
|
5853
|
-
Object.defineProperty(resolveSymlink, "__esModule", { value: true });
|
|
5854
|
-
resolveSymlink.build = void 0;
|
|
5855
|
-
const fs_1 = __importDefault(require$$0$5);
|
|
5856
|
-
const path_1 = require$$0$4;
|
|
5857
|
-
const resolveSymlinksAsync = function (path, state, callback) {
|
|
5858
|
-
const { queue, options: { suppressErrors }, } = state;
|
|
5859
|
-
queue.enqueue();
|
|
5860
|
-
fs_1.default.realpath(path, (error, resolvedPath) => {
|
|
5861
|
-
if (error)
|
|
5862
|
-
return queue.dequeue(suppressErrors ? null : error, state);
|
|
5863
|
-
fs_1.default.stat(resolvedPath, (error, stat) => {
|
|
5864
|
-
if (error)
|
|
5865
|
-
return queue.dequeue(suppressErrors ? null : error, state);
|
|
5866
|
-
if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
|
|
5867
|
-
return queue.dequeue(null, state);
|
|
5868
|
-
callback(stat, resolvedPath);
|
|
5869
|
-
queue.dequeue(null, state);
|
|
5870
|
-
});
|
|
5871
|
-
});
|
|
5872
|
-
};
|
|
5873
|
-
const resolveSymlinks = function (path, state, callback) {
|
|
5874
|
-
const { queue, options: { suppressErrors }, } = state;
|
|
5875
|
-
queue.enqueue();
|
|
5876
|
-
try {
|
|
5877
|
-
const resolvedPath = fs_1.default.realpathSync(path);
|
|
5878
|
-
const stat = fs_1.default.statSync(resolvedPath);
|
|
5879
|
-
if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
|
|
5880
|
-
return;
|
|
5881
|
-
callback(stat, resolvedPath);
|
|
5882
|
-
}
|
|
5883
|
-
catch (e) {
|
|
5884
|
-
if (!suppressErrors)
|
|
5885
|
-
throw e;
|
|
5886
|
-
}
|
|
5887
|
-
};
|
|
5888
|
-
function build(options, isSynchronous) {
|
|
5889
|
-
if (!options.resolveSymlinks || options.excludeSymlinks)
|
|
5890
|
-
return null;
|
|
5891
|
-
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
5892
|
-
}
|
|
5893
|
-
resolveSymlink.build = build;
|
|
5894
|
-
function isRecursive(path, resolved, state) {
|
|
5895
|
-
if (state.options.useRealPaths)
|
|
5896
|
-
return isRecursiveUsingRealPaths(resolved, state);
|
|
5897
|
-
let parent = (0, path_1.dirname)(path);
|
|
5898
|
-
let depth = 1;
|
|
5899
|
-
while (parent !== state.root && depth < 2) {
|
|
5900
|
-
const resolvedPath = state.symlinks.get(parent);
|
|
5901
|
-
const isSameRoot = !!resolvedPath &&
|
|
5902
|
-
(resolvedPath === resolved ||
|
|
5903
|
-
resolvedPath.startsWith(resolved) ||
|
|
5904
|
-
resolved.startsWith(resolvedPath));
|
|
5905
|
-
if (isSameRoot)
|
|
5906
|
-
depth++;
|
|
5907
|
-
else
|
|
5908
|
-
parent = (0, path_1.dirname)(parent);
|
|
5909
|
-
}
|
|
5910
|
-
state.symlinks.set(path, resolved);
|
|
5911
|
-
return depth > 1;
|
|
5791
|
+
function generateScopedClassName(strategy, name, filename) {
|
|
5792
|
+
if (strategy === "scoped") {
|
|
5793
|
+
return null;
|
|
5912
5794
|
}
|
|
5913
|
-
|
|
5914
|
-
|
|
5795
|
+
if (strategy === "non-scoped") {
|
|
5796
|
+
return name;
|
|
5915
5797
|
}
|
|
5916
|
-
|
|
5798
|
+
const hash = generateCssFilenameHash(filename);
|
|
5799
|
+
return `_${name}_${hash}`;
|
|
5917
5800
|
}
|
|
5918
5801
|
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
return state.counts;
|
|
5930
|
-
};
|
|
5931
|
-
const groupsSync = (state) => {
|
|
5932
|
-
return state.groups;
|
|
5933
|
-
};
|
|
5934
|
-
const defaultSync = (state) => {
|
|
5935
|
-
return state.paths;
|
|
5936
|
-
};
|
|
5937
|
-
const limitFilesSync = (state) => {
|
|
5938
|
-
return state.paths.slice(0, state.options.maxFiles);
|
|
5939
|
-
};
|
|
5940
|
-
const onlyCountsAsync = (state, error, callback) => {
|
|
5941
|
-
report(error, callback, state.counts, state.options.suppressErrors);
|
|
5942
|
-
return null;
|
|
5943
|
-
};
|
|
5944
|
-
const defaultAsync = (state, error, callback) => {
|
|
5945
|
-
report(error, callback, state.paths, state.options.suppressErrors);
|
|
5946
|
-
return null;
|
|
5947
|
-
};
|
|
5948
|
-
const limitFilesAsync = (state, error, callback) => {
|
|
5949
|
-
report(error, callback, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
5950
|
-
return null;
|
|
5951
|
-
};
|
|
5952
|
-
const groupsAsync = (state, error, callback) => {
|
|
5953
|
-
report(error, callback, state.groups, state.options.suppressErrors);
|
|
5954
|
-
return null;
|
|
5955
|
-
};
|
|
5956
|
-
function report(error, callback, output, suppressErrors) {
|
|
5957
|
-
if (error && !suppressErrors)
|
|
5958
|
-
callback(error, output);
|
|
5959
|
-
else
|
|
5960
|
-
callback(null, output);
|
|
5961
|
-
}
|
|
5962
|
-
function build(options, isSynchronous) {
|
|
5963
|
-
const { onlyCounts, group, maxFiles } = options;
|
|
5964
|
-
if (onlyCounts)
|
|
5965
|
-
return isSynchronous
|
|
5966
|
-
? onlyCountsSync
|
|
5967
|
-
: onlyCountsAsync;
|
|
5968
|
-
else if (group)
|
|
5969
|
-
return isSynchronous
|
|
5970
|
-
? groupsSync
|
|
5971
|
-
: groupsAsync;
|
|
5972
|
-
else if (maxFiles)
|
|
5973
|
-
return isSynchronous
|
|
5974
|
-
? limitFilesSync
|
|
5975
|
-
: limitFilesAsync;
|
|
5976
|
-
else
|
|
5977
|
-
return isSynchronous
|
|
5978
|
-
? defaultSync
|
|
5979
|
-
: defaultAsync;
|
|
5980
|
-
}
|
|
5981
|
-
invokeCallback.build = build;
|
|
5982
|
-
return invokeCallback;
|
|
5983
|
-
}
|
|
5984
|
-
|
|
5985
|
-
var walkDirectory = {};
|
|
5986
|
-
|
|
5987
|
-
var hasRequiredWalkDirectory;
|
|
5988
|
-
|
|
5989
|
-
function requireWalkDirectory () {
|
|
5990
|
-
if (hasRequiredWalkDirectory) return walkDirectory;
|
|
5991
|
-
hasRequiredWalkDirectory = 1;
|
|
5992
|
-
var __importDefault = (walkDirectory && walkDirectory.__importDefault) || function (mod) {
|
|
5993
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5994
|
-
};
|
|
5995
|
-
Object.defineProperty(walkDirectory, "__esModule", { value: true });
|
|
5996
|
-
walkDirectory.build = void 0;
|
|
5997
|
-
const fs_1 = __importDefault(require$$0$5);
|
|
5998
|
-
const readdirOpts = { withFileTypes: true };
|
|
5999
|
-
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
|
|
6000
|
-
if (currentDepth < 0)
|
|
6001
|
-
return state.queue.dequeue(null, state);
|
|
6002
|
-
state.visited.push(crawlPath);
|
|
6003
|
-
state.counts.directories++;
|
|
6004
|
-
state.queue.enqueue();
|
|
6005
|
-
// Perf: Node >= 10 introduced withFileTypes that helps us
|
|
6006
|
-
// skip an extra fs.stat call.
|
|
6007
|
-
fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
6008
|
-
callback(entries, directoryPath, currentDepth);
|
|
6009
|
-
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
6010
|
-
});
|
|
6011
|
-
};
|
|
6012
|
-
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
|
|
6013
|
-
if (currentDepth < 0)
|
|
6014
|
-
return;
|
|
6015
|
-
state.visited.push(crawlPath);
|
|
6016
|
-
state.counts.directories++;
|
|
6017
|
-
let entries = [];
|
|
6018
|
-
try {
|
|
6019
|
-
entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
|
|
6020
|
-
}
|
|
6021
|
-
catch (e) {
|
|
6022
|
-
if (!state.options.suppressErrors)
|
|
6023
|
-
throw e;
|
|
6024
|
-
}
|
|
6025
|
-
callback(entries, directoryPath, currentDepth);
|
|
6026
|
-
};
|
|
6027
|
-
function build(isSynchronous) {
|
|
6028
|
-
return isSynchronous ? walkSync : walkAsync;
|
|
6029
|
-
}
|
|
6030
|
-
walkDirectory.build = build;
|
|
6031
|
-
return walkDirectory;
|
|
6032
|
-
}
|
|
6033
|
-
|
|
6034
|
-
var queue = {};
|
|
6035
|
-
|
|
6036
|
-
var hasRequiredQueue;
|
|
6037
|
-
|
|
6038
|
-
function requireQueue () {
|
|
6039
|
-
if (hasRequiredQueue) return queue;
|
|
6040
|
-
hasRequiredQueue = 1;
|
|
6041
|
-
Object.defineProperty(queue, "__esModule", { value: true });
|
|
6042
|
-
queue.Queue = void 0;
|
|
6043
|
-
/**
|
|
6044
|
-
* This is a custom stateless queue to track concurrent async fs calls.
|
|
6045
|
-
* It increments a counter whenever a call is queued and decrements it
|
|
6046
|
-
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
6047
|
-
*/
|
|
6048
|
-
class Queue {
|
|
6049
|
-
onQueueEmpty;
|
|
6050
|
-
count = 0;
|
|
6051
|
-
constructor(onQueueEmpty) {
|
|
6052
|
-
this.onQueueEmpty = onQueueEmpty;
|
|
6053
|
-
}
|
|
6054
|
-
enqueue() {
|
|
6055
|
-
this.count++;
|
|
6056
|
-
}
|
|
6057
|
-
dequeue(error, output) {
|
|
6058
|
-
if (--this.count <= 0 || error)
|
|
6059
|
-
this.onQueueEmpty(error, output);
|
|
6060
|
-
}
|
|
6061
|
-
}
|
|
6062
|
-
queue.Queue = Queue;
|
|
6063
|
-
return queue;
|
|
6064
|
-
}
|
|
6065
|
-
|
|
6066
|
-
var counter = {};
|
|
6067
|
-
|
|
6068
|
-
var hasRequiredCounter;
|
|
6069
|
-
|
|
6070
|
-
function requireCounter () {
|
|
6071
|
-
if (hasRequiredCounter) return counter;
|
|
6072
|
-
hasRequiredCounter = 1;
|
|
6073
|
-
Object.defineProperty(counter, "__esModule", { value: true });
|
|
6074
|
-
counter.Counter = void 0;
|
|
6075
|
-
class Counter {
|
|
6076
|
-
_files = 0;
|
|
6077
|
-
_directories = 0;
|
|
6078
|
-
set files(num) {
|
|
6079
|
-
this._files = num;
|
|
6080
|
-
}
|
|
6081
|
-
get files() {
|
|
6082
|
-
return this._files;
|
|
6083
|
-
}
|
|
6084
|
-
set directories(num) {
|
|
6085
|
-
this._directories = num;
|
|
6086
|
-
}
|
|
6087
|
-
get directories() {
|
|
6088
|
-
return this._directories;
|
|
6089
|
-
}
|
|
6090
|
-
/**
|
|
6091
|
-
* @deprecated use `directories` instead
|
|
6092
|
-
*/
|
|
6093
|
-
/* c8 ignore next 3 */
|
|
6094
|
-
get dirs() {
|
|
6095
|
-
return this._directories;
|
|
6096
|
-
}
|
|
6097
|
-
}
|
|
6098
|
-
counter.Counter = Counter;
|
|
6099
|
-
return counter;
|
|
6100
|
-
}
|
|
6101
|
-
|
|
6102
|
-
var hasRequiredWalker;
|
|
6103
|
-
|
|
6104
|
-
function requireWalker () {
|
|
6105
|
-
if (hasRequiredWalker) return walker;
|
|
6106
|
-
hasRequiredWalker = 1;
|
|
6107
|
-
var __createBinding = (walker && walker.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6108
|
-
if (k2 === undefined) k2 = k;
|
|
6109
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6110
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6111
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6112
|
-
}
|
|
6113
|
-
Object.defineProperty(o, k2, desc);
|
|
6114
|
-
}) : (function(o, m, k, k2) {
|
|
6115
|
-
if (k2 === undefined) k2 = k;
|
|
6116
|
-
o[k2] = m[k];
|
|
6117
|
-
}));
|
|
6118
|
-
var __setModuleDefault = (walker && walker.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
6119
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
6120
|
-
}) : function(o, v) {
|
|
6121
|
-
o["default"] = v;
|
|
6122
|
-
});
|
|
6123
|
-
var __importStar = (walker && walker.__importStar) || function (mod) {
|
|
6124
|
-
if (mod && mod.__esModule) return mod;
|
|
6125
|
-
var result = {};
|
|
6126
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
6127
|
-
__setModuleDefault(result, mod);
|
|
6128
|
-
return result;
|
|
6129
|
-
};
|
|
6130
|
-
Object.defineProperty(walker, "__esModule", { value: true });
|
|
6131
|
-
walker.Walker = void 0;
|
|
6132
|
-
const path_1 = require$$0$4;
|
|
6133
|
-
const utils_1 = requireUtils$1();
|
|
6134
|
-
const joinPath = __importStar(requireJoinPath());
|
|
6135
|
-
const pushDirectory = __importStar(requirePushDirectory());
|
|
6136
|
-
const pushFile = __importStar(requirePushFile());
|
|
6137
|
-
const getArray = __importStar(requireGetArray());
|
|
6138
|
-
const groupFiles = __importStar(requireGroupFiles());
|
|
6139
|
-
const resolveSymlink = __importStar(requireResolveSymlink());
|
|
6140
|
-
const invokeCallback = __importStar(requireInvokeCallback());
|
|
6141
|
-
const walkDirectory = __importStar(requireWalkDirectory());
|
|
6142
|
-
const queue_1 = requireQueue();
|
|
6143
|
-
const counter_1 = requireCounter();
|
|
6144
|
-
class Walker {
|
|
6145
|
-
root;
|
|
6146
|
-
isSynchronous;
|
|
6147
|
-
state;
|
|
6148
|
-
joinPath;
|
|
6149
|
-
pushDirectory;
|
|
6150
|
-
pushFile;
|
|
6151
|
-
getArray;
|
|
6152
|
-
groupFiles;
|
|
6153
|
-
resolveSymlink;
|
|
6154
|
-
walkDirectory;
|
|
6155
|
-
callbackInvoker;
|
|
6156
|
-
constructor(root, options, callback) {
|
|
6157
|
-
this.isSynchronous = !callback;
|
|
6158
|
-
this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
|
|
6159
|
-
this.root = (0, utils_1.normalizePath)(root, options);
|
|
6160
|
-
this.state = {
|
|
6161
|
-
root: this.root.slice(0, -1),
|
|
6162
|
-
// Perf: we explicitly tell the compiler to optimize for String arrays
|
|
6163
|
-
paths: [""].slice(0, 0),
|
|
6164
|
-
groups: [],
|
|
6165
|
-
counts: new counter_1.Counter(),
|
|
6166
|
-
options,
|
|
6167
|
-
queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
|
|
6168
|
-
symlinks: new Map(),
|
|
6169
|
-
visited: [""].slice(0, 0),
|
|
6170
|
-
};
|
|
6171
|
-
/*
|
|
6172
|
-
* Perf: We conditionally change functions according to options. This gives a slight
|
|
6173
|
-
* performance boost. Since these functions are so small, they are automatically inlined
|
|
6174
|
-
* by the javascript engine so there's no function call overhead (in most cases).
|
|
6175
|
-
*/
|
|
6176
|
-
this.joinPath = joinPath.build(this.root, options);
|
|
6177
|
-
this.pushDirectory = pushDirectory.build(this.root, options);
|
|
6178
|
-
this.pushFile = pushFile.build(options);
|
|
6179
|
-
this.getArray = getArray.build(options);
|
|
6180
|
-
this.groupFiles = groupFiles.build(options);
|
|
6181
|
-
this.resolveSymlink = resolveSymlink.build(options, this.isSynchronous);
|
|
6182
|
-
this.walkDirectory = walkDirectory.build(this.isSynchronous);
|
|
6183
|
-
}
|
|
6184
|
-
start() {
|
|
6185
|
-
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
6186
|
-
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
6187
|
-
}
|
|
6188
|
-
walk = (entries, directoryPath, depth) => {
|
|
6189
|
-
const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;
|
|
6190
|
-
if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
|
|
6191
|
-
return;
|
|
6192
|
-
this.pushDirectory(directoryPath, paths, filters);
|
|
6193
|
-
const files = this.getArray(this.state.paths);
|
|
6194
|
-
for (let i = 0; i < entries.length; ++i) {
|
|
6195
|
-
const entry = entries[i];
|
|
6196
|
-
if (entry.isFile() ||
|
|
6197
|
-
(entry.isSymbolicLink() && !resolveSymlinks && !excludeSymlinks)) {
|
|
6198
|
-
const filename = this.joinPath(entry.name, directoryPath);
|
|
6199
|
-
this.pushFile(filename, files, this.state.counts, filters);
|
|
6200
|
-
}
|
|
6201
|
-
else if (entry.isDirectory()) {
|
|
6202
|
-
let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
6203
|
-
if (exclude && exclude(entry.name, path))
|
|
6204
|
-
continue;
|
|
6205
|
-
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
6206
|
-
}
|
|
6207
|
-
else if (entry.isSymbolicLink() && this.resolveSymlink) {
|
|
6208
|
-
let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
|
|
6209
|
-
this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
|
|
6210
|
-
if (stat.isDirectory()) {
|
|
6211
|
-
resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
|
|
6212
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator))
|
|
6213
|
-
return;
|
|
6214
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
6215
|
-
}
|
|
6216
|
-
else {
|
|
6217
|
-
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
6218
|
-
const filename = (0, path_1.basename)(resolvedPath);
|
|
6219
|
-
const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
|
|
6220
|
-
resolvedPath = this.joinPath(filename, directoryPath);
|
|
6221
|
-
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
6222
|
-
}
|
|
6223
|
-
});
|
|
6224
|
-
}
|
|
6225
|
-
}
|
|
6226
|
-
this.groupFiles(this.state.groups, directoryPath, files);
|
|
6227
|
-
};
|
|
6228
|
-
}
|
|
6229
|
-
walker.Walker = Walker;
|
|
6230
|
-
return walker;
|
|
6231
|
-
}
|
|
6232
|
-
|
|
6233
|
-
var hasRequiredAsync;
|
|
6234
|
-
|
|
6235
|
-
function requireAsync () {
|
|
6236
|
-
if (hasRequiredAsync) return async;
|
|
6237
|
-
hasRequiredAsync = 1;
|
|
6238
|
-
Object.defineProperty(async, "__esModule", { value: true });
|
|
6239
|
-
async.callback = async.promise = void 0;
|
|
6240
|
-
const walker_1 = requireWalker();
|
|
6241
|
-
function promise(root, options) {
|
|
6242
|
-
return new Promise((resolve, reject) => {
|
|
6243
|
-
callback(root, options, (err, output) => {
|
|
6244
|
-
if (err)
|
|
6245
|
-
return reject(err);
|
|
6246
|
-
resolve(output);
|
|
6247
|
-
});
|
|
6248
|
-
});
|
|
6249
|
-
}
|
|
6250
|
-
async.promise = promise;
|
|
6251
|
-
function callback(root, options, callback) {
|
|
6252
|
-
let walker = new walker_1.Walker(root, options, callback);
|
|
6253
|
-
walker.start();
|
|
6254
|
-
}
|
|
6255
|
-
async.callback = callback;
|
|
6256
|
-
return async;
|
|
6257
|
-
}
|
|
6258
|
-
|
|
6259
|
-
var sync = {};
|
|
6260
|
-
|
|
6261
|
-
var hasRequiredSync;
|
|
6262
|
-
|
|
6263
|
-
function requireSync () {
|
|
6264
|
-
if (hasRequiredSync) return sync;
|
|
6265
|
-
hasRequiredSync = 1;
|
|
6266
|
-
Object.defineProperty(sync, "__esModule", { value: true });
|
|
6267
|
-
sync.sync = void 0;
|
|
6268
|
-
const walker_1 = requireWalker();
|
|
6269
|
-
function sync$1(root, options) {
|
|
6270
|
-
const walker = new walker_1.Walker(root, options);
|
|
6271
|
-
return walker.start();
|
|
6272
|
-
}
|
|
6273
|
-
sync.sync = sync$1;
|
|
6274
|
-
return sync;
|
|
6275
|
-
}
|
|
6276
|
-
|
|
6277
|
-
var hasRequiredApiBuilder;
|
|
6278
|
-
|
|
6279
|
-
function requireApiBuilder () {
|
|
6280
|
-
if (hasRequiredApiBuilder) return apiBuilder;
|
|
6281
|
-
hasRequiredApiBuilder = 1;
|
|
6282
|
-
Object.defineProperty(apiBuilder, "__esModule", { value: true });
|
|
6283
|
-
apiBuilder.APIBuilder = void 0;
|
|
6284
|
-
const async_1 = requireAsync();
|
|
6285
|
-
const sync_1 = requireSync();
|
|
6286
|
-
class APIBuilder {
|
|
6287
|
-
root;
|
|
6288
|
-
options;
|
|
6289
|
-
constructor(root, options) {
|
|
6290
|
-
this.root = root;
|
|
6291
|
-
this.options = options;
|
|
6292
|
-
}
|
|
6293
|
-
withPromise() {
|
|
6294
|
-
return (0, async_1.promise)(this.root, this.options);
|
|
6295
|
-
}
|
|
6296
|
-
withCallback(cb) {
|
|
6297
|
-
(0, async_1.callback)(this.root, this.options, cb);
|
|
6298
|
-
}
|
|
6299
|
-
sync() {
|
|
6300
|
-
return (0, sync_1.sync)(this.root, this.options);
|
|
6301
|
-
}
|
|
6302
|
-
}
|
|
6303
|
-
apiBuilder.APIBuilder = APIBuilder;
|
|
6304
|
-
return apiBuilder;
|
|
6305
|
-
}
|
|
6306
|
-
|
|
6307
|
-
var utils = {};
|
|
6308
|
-
|
|
6309
|
-
var constants;
|
|
6310
|
-
var hasRequiredConstants;
|
|
6311
|
-
|
|
6312
|
-
function requireConstants () {
|
|
6313
|
-
if (hasRequiredConstants) return constants;
|
|
6314
|
-
hasRequiredConstants = 1;
|
|
6315
|
-
|
|
6316
|
-
const WIN_SLASH = '\\\\/';
|
|
6317
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
6318
|
-
|
|
6319
|
-
/**
|
|
6320
|
-
* Posix glob regex
|
|
6321
|
-
*/
|
|
6322
|
-
|
|
6323
|
-
const DOT_LITERAL = '\\.';
|
|
6324
|
-
const PLUS_LITERAL = '\\+';
|
|
6325
|
-
const QMARK_LITERAL = '\\?';
|
|
6326
|
-
const SLASH_LITERAL = '\\/';
|
|
6327
|
-
const ONE_CHAR = '(?=.)';
|
|
6328
|
-
const QMARK = '[^/]';
|
|
6329
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
6330
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
6331
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
6332
|
-
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
6333
|
-
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
6334
|
-
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
6335
|
-
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
6336
|
-
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
6337
|
-
const STAR = `${QMARK}*?`;
|
|
6338
|
-
const SEP = '/';
|
|
6339
|
-
|
|
6340
|
-
const POSIX_CHARS = {
|
|
6341
|
-
DOT_LITERAL,
|
|
6342
|
-
PLUS_LITERAL,
|
|
6343
|
-
QMARK_LITERAL,
|
|
6344
|
-
SLASH_LITERAL,
|
|
6345
|
-
ONE_CHAR,
|
|
6346
|
-
QMARK,
|
|
6347
|
-
END_ANCHOR,
|
|
6348
|
-
DOTS_SLASH,
|
|
6349
|
-
NO_DOT,
|
|
6350
|
-
NO_DOTS,
|
|
6351
|
-
NO_DOT_SLASH,
|
|
6352
|
-
NO_DOTS_SLASH,
|
|
6353
|
-
QMARK_NO_DOT,
|
|
6354
|
-
STAR,
|
|
6355
|
-
START_ANCHOR,
|
|
6356
|
-
SEP
|
|
6357
|
-
};
|
|
6358
|
-
|
|
6359
|
-
/**
|
|
6360
|
-
* Windows glob regex
|
|
6361
|
-
*/
|
|
6362
|
-
|
|
6363
|
-
const WINDOWS_CHARS = {
|
|
6364
|
-
...POSIX_CHARS,
|
|
6365
|
-
|
|
6366
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
6367
|
-
QMARK: WIN_NO_SLASH,
|
|
6368
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
6369
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
6370
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
6371
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6372
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
6373
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6374
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
6375
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
6376
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
6377
|
-
SEP: '\\'
|
|
6378
|
-
};
|
|
6379
|
-
|
|
6380
|
-
/**
|
|
6381
|
-
* POSIX Bracket Regex
|
|
6382
|
-
*/
|
|
6383
|
-
|
|
6384
|
-
const POSIX_REGEX_SOURCE = {
|
|
6385
|
-
alnum: 'a-zA-Z0-9',
|
|
6386
|
-
alpha: 'a-zA-Z',
|
|
6387
|
-
ascii: '\\x00-\\x7F',
|
|
6388
|
-
blank: ' \\t',
|
|
6389
|
-
cntrl: '\\x00-\\x1F\\x7F',
|
|
6390
|
-
digit: '0-9',
|
|
6391
|
-
graph: '\\x21-\\x7E',
|
|
6392
|
-
lower: 'a-z',
|
|
6393
|
-
print: '\\x20-\\x7E ',
|
|
6394
|
-
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
6395
|
-
space: ' \\t\\r\\n\\v\\f',
|
|
6396
|
-
upper: 'A-Z',
|
|
6397
|
-
word: 'A-Za-z0-9_',
|
|
6398
|
-
xdigit: 'A-Fa-f0-9'
|
|
6399
|
-
};
|
|
6400
|
-
|
|
6401
|
-
constants = {
|
|
6402
|
-
MAX_LENGTH: 1024 * 64,
|
|
6403
|
-
POSIX_REGEX_SOURCE,
|
|
6404
|
-
|
|
6405
|
-
// regular expressions
|
|
6406
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
6407
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
6408
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
6409
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
6410
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
6411
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
6412
|
-
|
|
6413
|
-
// Replace globs with equivalent patterns to reduce parsing time.
|
|
6414
|
-
REPLACEMENTS: {
|
|
6415
|
-
'***': '*',
|
|
6416
|
-
'**/**': '**',
|
|
6417
|
-
'**/**/**': '**'
|
|
6418
|
-
},
|
|
6419
|
-
|
|
6420
|
-
// Digits
|
|
6421
|
-
CHAR_0: 48, /* 0 */
|
|
6422
|
-
CHAR_9: 57, /* 9 */
|
|
6423
|
-
|
|
6424
|
-
// Alphabet chars.
|
|
6425
|
-
CHAR_UPPERCASE_A: 65, /* A */
|
|
6426
|
-
CHAR_LOWERCASE_A: 97, /* a */
|
|
6427
|
-
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
6428
|
-
CHAR_LOWERCASE_Z: 122, /* z */
|
|
6429
|
-
|
|
6430
|
-
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
6431
|
-
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
6432
|
-
|
|
6433
|
-
CHAR_ASTERISK: 42, /* * */
|
|
6434
|
-
|
|
6435
|
-
// Non-alphabetic chars.
|
|
6436
|
-
CHAR_AMPERSAND: 38, /* & */
|
|
6437
|
-
CHAR_AT: 64, /* @ */
|
|
6438
|
-
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
6439
|
-
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
6440
|
-
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
6441
|
-
CHAR_COLON: 58, /* : */
|
|
6442
|
-
CHAR_COMMA: 44, /* , */
|
|
6443
|
-
CHAR_DOT: 46, /* . */
|
|
6444
|
-
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
6445
|
-
CHAR_EQUAL: 61, /* = */
|
|
6446
|
-
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
6447
|
-
CHAR_FORM_FEED: 12, /* \f */
|
|
6448
|
-
CHAR_FORWARD_SLASH: 47, /* / */
|
|
6449
|
-
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
6450
|
-
CHAR_HASH: 35, /* # */
|
|
6451
|
-
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
6452
|
-
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
6453
|
-
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
6454
|
-
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
6455
|
-
CHAR_LINE_FEED: 10, /* \n */
|
|
6456
|
-
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
6457
|
-
CHAR_PERCENT: 37, /* % */
|
|
6458
|
-
CHAR_PLUS: 43, /* + */
|
|
6459
|
-
CHAR_QUESTION_MARK: 63, /* ? */
|
|
6460
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
6461
|
-
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
6462
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
6463
|
-
CHAR_SEMICOLON: 59, /* ; */
|
|
6464
|
-
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
6465
|
-
CHAR_SPACE: 32, /* */
|
|
6466
|
-
CHAR_TAB: 9, /* \t */
|
|
6467
|
-
CHAR_UNDERSCORE: 95, /* _ */
|
|
6468
|
-
CHAR_VERTICAL_LINE: 124, /* | */
|
|
6469
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
6470
|
-
|
|
6471
|
-
/**
|
|
6472
|
-
* Create EXTGLOB_CHARS
|
|
6473
|
-
*/
|
|
6474
|
-
|
|
6475
|
-
extglobChars(chars) {
|
|
6476
|
-
return {
|
|
6477
|
-
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
6478
|
-
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
6479
|
-
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
6480
|
-
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
6481
|
-
'@': { type: 'at', open: '(?:', close: ')' }
|
|
6482
|
-
};
|
|
6483
|
-
},
|
|
6484
|
-
|
|
6485
|
-
/**
|
|
6486
|
-
* Create GLOB_CHARS
|
|
6487
|
-
*/
|
|
6488
|
-
|
|
6489
|
-
globChars(win32) {
|
|
6490
|
-
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
6491
|
-
}
|
|
6492
|
-
};
|
|
6493
|
-
return constants;
|
|
6494
|
-
}
|
|
6495
|
-
|
|
6496
|
-
/*global navigator*/
|
|
6497
|
-
|
|
6498
|
-
var hasRequiredUtils;
|
|
6499
|
-
|
|
6500
|
-
function requireUtils () {
|
|
6501
|
-
if (hasRequiredUtils) return utils;
|
|
6502
|
-
hasRequiredUtils = 1;
|
|
6503
|
-
(function (exports) {
|
|
6504
|
-
|
|
6505
|
-
const {
|
|
6506
|
-
REGEX_BACKSLASH,
|
|
6507
|
-
REGEX_REMOVE_BACKSLASH,
|
|
6508
|
-
REGEX_SPECIAL_CHARS,
|
|
6509
|
-
REGEX_SPECIAL_CHARS_GLOBAL
|
|
6510
|
-
} = requireConstants();
|
|
6511
|
-
|
|
6512
|
-
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
6513
|
-
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
6514
|
-
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
6515
|
-
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
6516
|
-
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
6517
|
-
|
|
6518
|
-
exports.isWindows = () => {
|
|
6519
|
-
if (typeof navigator !== 'undefined' && navigator.platform) {
|
|
6520
|
-
const platform = navigator.platform.toLowerCase();
|
|
6521
|
-
return platform === 'win32' || platform === 'windows';
|
|
6522
|
-
}
|
|
6523
|
-
|
|
6524
|
-
if (typeof process !== 'undefined' && process.platform) {
|
|
6525
|
-
return process.platform === 'win32';
|
|
6526
|
-
}
|
|
6527
|
-
|
|
6528
|
-
return false;
|
|
6529
|
-
};
|
|
6530
|
-
|
|
6531
|
-
exports.removeBackslashes = str => {
|
|
6532
|
-
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
6533
|
-
return match === '\\' ? '' : match;
|
|
6534
|
-
});
|
|
6535
|
-
};
|
|
6536
|
-
|
|
6537
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
6538
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
6539
|
-
if (idx === -1) return input;
|
|
6540
|
-
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
6541
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
6542
|
-
};
|
|
6543
|
-
|
|
6544
|
-
exports.removePrefix = (input, state = {}) => {
|
|
6545
|
-
let output = input;
|
|
6546
|
-
if (output.startsWith('./')) {
|
|
6547
|
-
output = output.slice(2);
|
|
6548
|
-
state.prefix = './';
|
|
6549
|
-
}
|
|
6550
|
-
return output;
|
|
6551
|
-
};
|
|
6552
|
-
|
|
6553
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
6554
|
-
const prepend = options.contains ? '' : '^';
|
|
6555
|
-
const append = options.contains ? '' : '$';
|
|
6556
|
-
|
|
6557
|
-
let output = `${prepend}(?:${input})${append}`;
|
|
6558
|
-
if (state.negated === true) {
|
|
6559
|
-
output = `(?:^(?!${output}).*$)`;
|
|
6560
|
-
}
|
|
6561
|
-
return output;
|
|
6562
|
-
};
|
|
6563
|
-
|
|
6564
|
-
exports.basename = (path, { windows } = {}) => {
|
|
6565
|
-
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
6566
|
-
const last = segs[segs.length - 1];
|
|
6567
|
-
|
|
6568
|
-
if (last === '') {
|
|
6569
|
-
return segs[segs.length - 2];
|
|
6570
|
-
}
|
|
6571
|
-
|
|
6572
|
-
return last;
|
|
6573
|
-
};
|
|
6574
|
-
} (utils));
|
|
6575
|
-
return utils;
|
|
6576
|
-
}
|
|
6577
|
-
|
|
6578
|
-
var scan_1;
|
|
6579
|
-
var hasRequiredScan;
|
|
6580
|
-
|
|
6581
|
-
function requireScan () {
|
|
6582
|
-
if (hasRequiredScan) return scan_1;
|
|
6583
|
-
hasRequiredScan = 1;
|
|
6584
|
-
|
|
6585
|
-
const utils = requireUtils();
|
|
6586
|
-
const {
|
|
6587
|
-
CHAR_ASTERISK, /* * */
|
|
6588
|
-
CHAR_AT, /* @ */
|
|
6589
|
-
CHAR_BACKWARD_SLASH, /* \ */
|
|
6590
|
-
CHAR_COMMA, /* , */
|
|
6591
|
-
CHAR_DOT, /* . */
|
|
6592
|
-
CHAR_EXCLAMATION_MARK, /* ! */
|
|
6593
|
-
CHAR_FORWARD_SLASH, /* / */
|
|
6594
|
-
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
6595
|
-
CHAR_LEFT_PARENTHESES, /* ( */
|
|
6596
|
-
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
6597
|
-
CHAR_PLUS, /* + */
|
|
6598
|
-
CHAR_QUESTION_MARK, /* ? */
|
|
6599
|
-
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
6600
|
-
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
6601
|
-
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
6602
|
-
} = requireConstants();
|
|
6603
|
-
|
|
6604
|
-
const isPathSeparator = code => {
|
|
6605
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
6606
|
-
};
|
|
6607
|
-
|
|
6608
|
-
const depth = token => {
|
|
6609
|
-
if (token.isPrefix !== true) {
|
|
6610
|
-
token.depth = token.isGlobstar ? Infinity : 1;
|
|
6611
|
-
}
|
|
6612
|
-
};
|
|
6613
|
-
|
|
6614
|
-
/**
|
|
6615
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
6616
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
6617
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
6618
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
6619
|
-
*
|
|
6620
|
-
* ```js
|
|
6621
|
-
* const pm = require('picomatch');
|
|
6622
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
6623
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
6624
|
-
* ```
|
|
6625
|
-
* @param {String} `str`
|
|
6626
|
-
* @param {Object} `options`
|
|
6627
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
6628
|
-
* @api public
|
|
6629
|
-
*/
|
|
6630
|
-
|
|
6631
|
-
const scan = (input, options) => {
|
|
6632
|
-
const opts = options || {};
|
|
6633
|
-
|
|
6634
|
-
const length = input.length - 1;
|
|
6635
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
6636
|
-
const slashes = [];
|
|
6637
|
-
const tokens = [];
|
|
6638
|
-
const parts = [];
|
|
6639
|
-
|
|
6640
|
-
let str = input;
|
|
6641
|
-
let index = -1;
|
|
6642
|
-
let start = 0;
|
|
6643
|
-
let lastIndex = 0;
|
|
6644
|
-
let isBrace = false;
|
|
6645
|
-
let isBracket = false;
|
|
6646
|
-
let isGlob = false;
|
|
6647
|
-
let isExtglob = false;
|
|
6648
|
-
let isGlobstar = false;
|
|
6649
|
-
let braceEscaped = false;
|
|
6650
|
-
let backslashes = false;
|
|
6651
|
-
let negated = false;
|
|
6652
|
-
let negatedExtglob = false;
|
|
6653
|
-
let finished = false;
|
|
6654
|
-
let braces = 0;
|
|
6655
|
-
let prev;
|
|
6656
|
-
let code;
|
|
6657
|
-
let token = { value: '', depth: 0, isGlob: false };
|
|
6658
|
-
|
|
6659
|
-
const eos = () => index >= length;
|
|
6660
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
6661
|
-
const advance = () => {
|
|
6662
|
-
prev = code;
|
|
6663
|
-
return str.charCodeAt(++index);
|
|
6664
|
-
};
|
|
6665
|
-
|
|
6666
|
-
while (index < length) {
|
|
6667
|
-
code = advance();
|
|
6668
|
-
let next;
|
|
6669
|
-
|
|
6670
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
6671
|
-
backslashes = token.backslashes = true;
|
|
6672
|
-
code = advance();
|
|
6673
|
-
|
|
6674
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6675
|
-
braceEscaped = true;
|
|
6676
|
-
}
|
|
6677
|
-
continue;
|
|
6678
|
-
}
|
|
6679
|
-
|
|
6680
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
6681
|
-
braces++;
|
|
6682
|
-
|
|
6683
|
-
while (eos() !== true && (code = advance())) {
|
|
6684
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
6685
|
-
backslashes = token.backslashes = true;
|
|
6686
|
-
advance();
|
|
6687
|
-
continue;
|
|
6688
|
-
}
|
|
6689
|
-
|
|
6690
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6691
|
-
braces++;
|
|
6692
|
-
continue;
|
|
6693
|
-
}
|
|
6694
|
-
|
|
6695
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
6696
|
-
isBrace = token.isBrace = true;
|
|
6697
|
-
isGlob = token.isGlob = true;
|
|
6698
|
-
finished = true;
|
|
6699
|
-
|
|
6700
|
-
if (scanToEnd === true) {
|
|
6701
|
-
continue;
|
|
6702
|
-
}
|
|
6703
|
-
|
|
6704
|
-
break;
|
|
6705
|
-
}
|
|
6706
|
-
|
|
6707
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
6708
|
-
isBrace = token.isBrace = true;
|
|
6709
|
-
isGlob = token.isGlob = true;
|
|
6710
|
-
finished = true;
|
|
6711
|
-
|
|
6712
|
-
if (scanToEnd === true) {
|
|
6713
|
-
continue;
|
|
6714
|
-
}
|
|
6715
|
-
|
|
6716
|
-
break;
|
|
6717
|
-
}
|
|
6718
|
-
|
|
6719
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
6720
|
-
braces--;
|
|
6721
|
-
|
|
6722
|
-
if (braces === 0) {
|
|
6723
|
-
braceEscaped = false;
|
|
6724
|
-
isBrace = token.isBrace = true;
|
|
6725
|
-
finished = true;
|
|
6726
|
-
break;
|
|
6727
|
-
}
|
|
6728
|
-
}
|
|
6729
|
-
}
|
|
6730
|
-
|
|
6731
|
-
if (scanToEnd === true) {
|
|
6732
|
-
continue;
|
|
6733
|
-
}
|
|
6734
|
-
|
|
6735
|
-
break;
|
|
6736
|
-
}
|
|
6737
|
-
|
|
6738
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
6739
|
-
slashes.push(index);
|
|
6740
|
-
tokens.push(token);
|
|
6741
|
-
token = { value: '', depth: 0, isGlob: false };
|
|
6742
|
-
|
|
6743
|
-
if (finished === true) continue;
|
|
6744
|
-
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
6745
|
-
start += 2;
|
|
6746
|
-
continue;
|
|
6747
|
-
}
|
|
6748
|
-
|
|
6749
|
-
lastIndex = index + 1;
|
|
6750
|
-
continue;
|
|
6751
|
-
}
|
|
6752
|
-
|
|
6753
|
-
if (opts.noext !== true) {
|
|
6754
|
-
const isExtglobChar = code === CHAR_PLUS
|
|
6755
|
-
|| code === CHAR_AT
|
|
6756
|
-
|| code === CHAR_ASTERISK
|
|
6757
|
-
|| code === CHAR_QUESTION_MARK
|
|
6758
|
-
|| code === CHAR_EXCLAMATION_MARK;
|
|
6759
|
-
|
|
6760
|
-
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
6761
|
-
isGlob = token.isGlob = true;
|
|
6762
|
-
isExtglob = token.isExtglob = true;
|
|
6763
|
-
finished = true;
|
|
6764
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6765
|
-
negatedExtglob = true;
|
|
6766
|
-
}
|
|
6767
|
-
|
|
6768
|
-
if (scanToEnd === true) {
|
|
6769
|
-
while (eos() !== true && (code = advance())) {
|
|
6770
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
6771
|
-
backslashes = token.backslashes = true;
|
|
6772
|
-
code = advance();
|
|
6773
|
-
continue;
|
|
6774
|
-
}
|
|
6775
|
-
|
|
6776
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6777
|
-
isGlob = token.isGlob = true;
|
|
6778
|
-
finished = true;
|
|
6779
|
-
break;
|
|
6780
|
-
}
|
|
6781
|
-
}
|
|
6782
|
-
continue;
|
|
6783
|
-
}
|
|
6784
|
-
break;
|
|
6785
|
-
}
|
|
6786
|
-
}
|
|
6787
|
-
|
|
6788
|
-
if (code === CHAR_ASTERISK) {
|
|
6789
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
6790
|
-
isGlob = token.isGlob = true;
|
|
6791
|
-
finished = true;
|
|
6792
|
-
|
|
6793
|
-
if (scanToEnd === true) {
|
|
6794
|
-
continue;
|
|
6795
|
-
}
|
|
6796
|
-
break;
|
|
6797
|
-
}
|
|
6798
|
-
|
|
6799
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
6800
|
-
isGlob = token.isGlob = true;
|
|
6801
|
-
finished = true;
|
|
6802
|
-
|
|
6803
|
-
if (scanToEnd === true) {
|
|
6804
|
-
continue;
|
|
6805
|
-
}
|
|
6806
|
-
break;
|
|
6807
|
-
}
|
|
6808
|
-
|
|
6809
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
6810
|
-
while (eos() !== true && (next = advance())) {
|
|
6811
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
6812
|
-
backslashes = token.backslashes = true;
|
|
6813
|
-
advance();
|
|
6814
|
-
continue;
|
|
6815
|
-
}
|
|
6816
|
-
|
|
6817
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
6818
|
-
isBracket = token.isBracket = true;
|
|
6819
|
-
isGlob = token.isGlob = true;
|
|
6820
|
-
finished = true;
|
|
6821
|
-
break;
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6824
|
-
|
|
6825
|
-
if (scanToEnd === true) {
|
|
6826
|
-
continue;
|
|
6827
|
-
}
|
|
6828
|
-
|
|
6829
|
-
break;
|
|
6830
|
-
}
|
|
6831
|
-
|
|
6832
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6833
|
-
negated = token.negated = true;
|
|
6834
|
-
start++;
|
|
6835
|
-
continue;
|
|
6836
|
-
}
|
|
6837
|
-
|
|
6838
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
6839
|
-
isGlob = token.isGlob = true;
|
|
6840
|
-
|
|
6841
|
-
if (scanToEnd === true) {
|
|
6842
|
-
while (eos() !== true && (code = advance())) {
|
|
6843
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
6844
|
-
backslashes = token.backslashes = true;
|
|
6845
|
-
code = advance();
|
|
6846
|
-
continue;
|
|
6847
|
-
}
|
|
6848
|
-
|
|
6849
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6850
|
-
finished = true;
|
|
6851
|
-
break;
|
|
6852
|
-
}
|
|
6853
|
-
}
|
|
6854
|
-
continue;
|
|
6855
|
-
}
|
|
6856
|
-
break;
|
|
6857
|
-
}
|
|
6858
|
-
|
|
6859
|
-
if (isGlob === true) {
|
|
6860
|
-
finished = true;
|
|
6861
|
-
|
|
6862
|
-
if (scanToEnd === true) {
|
|
6863
|
-
continue;
|
|
6864
|
-
}
|
|
6865
|
-
|
|
6866
|
-
break;
|
|
6867
|
-
}
|
|
6868
|
-
}
|
|
6869
|
-
|
|
6870
|
-
if (opts.noext === true) {
|
|
6871
|
-
isExtglob = false;
|
|
6872
|
-
isGlob = false;
|
|
6873
|
-
}
|
|
6874
|
-
|
|
6875
|
-
let base = str;
|
|
6876
|
-
let prefix = '';
|
|
6877
|
-
let glob = '';
|
|
6878
|
-
|
|
6879
|
-
if (start > 0) {
|
|
6880
|
-
prefix = str.slice(0, start);
|
|
6881
|
-
str = str.slice(start);
|
|
6882
|
-
lastIndex -= start;
|
|
6883
|
-
}
|
|
6884
|
-
|
|
6885
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
6886
|
-
base = str.slice(0, lastIndex);
|
|
6887
|
-
glob = str.slice(lastIndex);
|
|
6888
|
-
} else if (isGlob === true) {
|
|
6889
|
-
base = '';
|
|
6890
|
-
glob = str;
|
|
6891
|
-
} else {
|
|
6892
|
-
base = str;
|
|
6893
|
-
}
|
|
6894
|
-
|
|
6895
|
-
if (base && base !== '' && base !== '/' && base !== str) {
|
|
6896
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
6897
|
-
base = base.slice(0, -1);
|
|
6898
|
-
}
|
|
6899
|
-
}
|
|
6900
|
-
|
|
6901
|
-
if (opts.unescape === true) {
|
|
6902
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
6903
|
-
|
|
6904
|
-
if (base && backslashes === true) {
|
|
6905
|
-
base = utils.removeBackslashes(base);
|
|
6906
|
-
}
|
|
6907
|
-
}
|
|
6908
|
-
|
|
6909
|
-
const state = {
|
|
6910
|
-
prefix,
|
|
6911
|
-
input,
|
|
6912
|
-
start,
|
|
6913
|
-
base,
|
|
6914
|
-
glob,
|
|
6915
|
-
isBrace,
|
|
6916
|
-
isBracket,
|
|
6917
|
-
isGlob,
|
|
6918
|
-
isExtglob,
|
|
6919
|
-
isGlobstar,
|
|
6920
|
-
negated,
|
|
6921
|
-
negatedExtglob
|
|
6922
|
-
};
|
|
6923
|
-
|
|
6924
|
-
if (opts.tokens === true) {
|
|
6925
|
-
state.maxDepth = 0;
|
|
6926
|
-
if (!isPathSeparator(code)) {
|
|
6927
|
-
tokens.push(token);
|
|
6928
|
-
}
|
|
6929
|
-
state.tokens = tokens;
|
|
6930
|
-
}
|
|
6931
|
-
|
|
6932
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
6933
|
-
let prevIndex;
|
|
6934
|
-
|
|
6935
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
6936
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
6937
|
-
const i = slashes[idx];
|
|
6938
|
-
const value = input.slice(n, i);
|
|
6939
|
-
if (opts.tokens) {
|
|
6940
|
-
if (idx === 0 && start !== 0) {
|
|
6941
|
-
tokens[idx].isPrefix = true;
|
|
6942
|
-
tokens[idx].value = prefix;
|
|
6943
|
-
} else {
|
|
6944
|
-
tokens[idx].value = value;
|
|
6945
|
-
}
|
|
6946
|
-
depth(tokens[idx]);
|
|
6947
|
-
state.maxDepth += tokens[idx].depth;
|
|
6948
|
-
}
|
|
6949
|
-
if (idx !== 0 || value !== '') {
|
|
6950
|
-
parts.push(value);
|
|
6951
|
-
}
|
|
6952
|
-
prevIndex = i;
|
|
6953
|
-
}
|
|
6954
|
-
|
|
6955
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
6956
|
-
const value = input.slice(prevIndex + 1);
|
|
6957
|
-
parts.push(value);
|
|
6958
|
-
|
|
6959
|
-
if (opts.tokens) {
|
|
6960
|
-
tokens[tokens.length - 1].value = value;
|
|
6961
|
-
depth(tokens[tokens.length - 1]);
|
|
6962
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
6963
|
-
}
|
|
6964
|
-
}
|
|
6965
|
-
|
|
6966
|
-
state.slashes = slashes;
|
|
6967
|
-
state.parts = parts;
|
|
6968
|
-
}
|
|
6969
|
-
|
|
6970
|
-
return state;
|
|
6971
|
-
};
|
|
6972
|
-
|
|
6973
|
-
scan_1 = scan;
|
|
6974
|
-
return scan_1;
|
|
6975
|
-
}
|
|
6976
|
-
|
|
6977
|
-
var parse_1;
|
|
6978
|
-
var hasRequiredParse;
|
|
6979
|
-
|
|
6980
|
-
function requireParse () {
|
|
6981
|
-
if (hasRequiredParse) return parse_1;
|
|
6982
|
-
hasRequiredParse = 1;
|
|
6983
|
-
|
|
6984
|
-
const constants = requireConstants();
|
|
6985
|
-
const utils = requireUtils();
|
|
6986
|
-
|
|
6987
|
-
/**
|
|
6988
|
-
* Constants
|
|
6989
|
-
*/
|
|
6990
|
-
|
|
6991
|
-
const {
|
|
6992
|
-
MAX_LENGTH,
|
|
6993
|
-
POSIX_REGEX_SOURCE,
|
|
6994
|
-
REGEX_NON_SPECIAL_CHARS,
|
|
6995
|
-
REGEX_SPECIAL_CHARS_BACKREF,
|
|
6996
|
-
REPLACEMENTS
|
|
6997
|
-
} = constants;
|
|
6998
|
-
|
|
6999
|
-
/**
|
|
7000
|
-
* Helpers
|
|
7001
|
-
*/
|
|
7002
|
-
|
|
7003
|
-
const expandRange = (args, options) => {
|
|
7004
|
-
if (typeof options.expandRange === 'function') {
|
|
7005
|
-
return options.expandRange(...args, options);
|
|
7006
|
-
}
|
|
7007
|
-
|
|
7008
|
-
args.sort();
|
|
7009
|
-
const value = `[${args.join('-')}]`;
|
|
7010
|
-
|
|
7011
|
-
try {
|
|
7012
|
-
/* eslint-disable-next-line no-new */
|
|
7013
|
-
new RegExp(value);
|
|
7014
|
-
} catch (ex) {
|
|
7015
|
-
return args.map(v => utils.escapeRegex(v)).join('..');
|
|
7016
|
-
}
|
|
7017
|
-
|
|
7018
|
-
return value;
|
|
7019
|
-
};
|
|
7020
|
-
|
|
7021
|
-
/**
|
|
7022
|
-
* Create the message for a syntax error
|
|
7023
|
-
*/
|
|
7024
|
-
|
|
7025
|
-
const syntaxError = (type, char) => {
|
|
7026
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
7027
|
-
};
|
|
7028
|
-
|
|
7029
|
-
/**
|
|
7030
|
-
* Parse the given input string.
|
|
7031
|
-
* @param {String} input
|
|
7032
|
-
* @param {Object} options
|
|
7033
|
-
* @return {Object}
|
|
7034
|
-
*/
|
|
7035
|
-
|
|
7036
|
-
const parse = (input, options) => {
|
|
7037
|
-
if (typeof input !== 'string') {
|
|
7038
|
-
throw new TypeError('Expected a string');
|
|
7039
|
-
}
|
|
7040
|
-
|
|
7041
|
-
input = REPLACEMENTS[input] || input;
|
|
7042
|
-
|
|
7043
|
-
const opts = { ...options };
|
|
7044
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7045
|
-
|
|
7046
|
-
let len = input.length;
|
|
7047
|
-
if (len > max) {
|
|
7048
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
7049
|
-
}
|
|
7050
|
-
|
|
7051
|
-
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
7052
|
-
const tokens = [bos];
|
|
7053
|
-
|
|
7054
|
-
const capture = opts.capture ? '' : '?:';
|
|
7055
|
-
|
|
7056
|
-
// create constants based on platform, for windows or posix
|
|
7057
|
-
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
7058
|
-
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
7059
|
-
|
|
7060
|
-
const {
|
|
7061
|
-
DOT_LITERAL,
|
|
7062
|
-
PLUS_LITERAL,
|
|
7063
|
-
SLASH_LITERAL,
|
|
7064
|
-
ONE_CHAR,
|
|
7065
|
-
DOTS_SLASH,
|
|
7066
|
-
NO_DOT,
|
|
7067
|
-
NO_DOT_SLASH,
|
|
7068
|
-
NO_DOTS_SLASH,
|
|
7069
|
-
QMARK,
|
|
7070
|
-
QMARK_NO_DOT,
|
|
7071
|
-
STAR,
|
|
7072
|
-
START_ANCHOR
|
|
7073
|
-
} = PLATFORM_CHARS;
|
|
7074
|
-
|
|
7075
|
-
const globstar = opts => {
|
|
7076
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
7077
|
-
};
|
|
7078
|
-
|
|
7079
|
-
const nodot = opts.dot ? '' : NO_DOT;
|
|
7080
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
7081
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
7082
|
-
|
|
7083
|
-
if (opts.capture) {
|
|
7084
|
-
star = `(${star})`;
|
|
7085
|
-
}
|
|
7086
|
-
|
|
7087
|
-
// minimatch options support
|
|
7088
|
-
if (typeof opts.noext === 'boolean') {
|
|
7089
|
-
opts.noextglob = opts.noext;
|
|
7090
|
-
}
|
|
7091
|
-
|
|
7092
|
-
const state = {
|
|
7093
|
-
input,
|
|
7094
|
-
index: -1,
|
|
7095
|
-
start: 0,
|
|
7096
|
-
dot: opts.dot === true,
|
|
7097
|
-
consumed: '',
|
|
7098
|
-
output: '',
|
|
7099
|
-
prefix: '',
|
|
7100
|
-
backtrack: false,
|
|
7101
|
-
negated: false,
|
|
7102
|
-
brackets: 0,
|
|
7103
|
-
braces: 0,
|
|
7104
|
-
parens: 0,
|
|
7105
|
-
quotes: 0,
|
|
7106
|
-
globstar: false,
|
|
7107
|
-
tokens
|
|
7108
|
-
};
|
|
7109
|
-
|
|
7110
|
-
input = utils.removePrefix(input, state);
|
|
7111
|
-
len = input.length;
|
|
7112
|
-
|
|
7113
|
-
const extglobs = [];
|
|
7114
|
-
const braces = [];
|
|
7115
|
-
const stack = [];
|
|
7116
|
-
let prev = bos;
|
|
7117
|
-
let value;
|
|
7118
|
-
|
|
7119
|
-
/**
|
|
7120
|
-
* Tokenizing helpers
|
|
7121
|
-
*/
|
|
7122
|
-
|
|
7123
|
-
const eos = () => state.index === len - 1;
|
|
7124
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
7125
|
-
const advance = state.advance = () => input[++state.index] || '';
|
|
7126
|
-
const remaining = () => input.slice(state.index + 1);
|
|
7127
|
-
const consume = (value = '', num = 0) => {
|
|
7128
|
-
state.consumed += value;
|
|
7129
|
-
state.index += num;
|
|
7130
|
-
};
|
|
7131
|
-
|
|
7132
|
-
const append = token => {
|
|
7133
|
-
state.output += token.output != null ? token.output : token.value;
|
|
7134
|
-
consume(token.value);
|
|
7135
|
-
};
|
|
7136
|
-
|
|
7137
|
-
const negate = () => {
|
|
7138
|
-
let count = 1;
|
|
7139
|
-
|
|
7140
|
-
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
7141
|
-
advance();
|
|
7142
|
-
state.start++;
|
|
7143
|
-
count++;
|
|
7144
|
-
}
|
|
7145
|
-
|
|
7146
|
-
if (count % 2 === 0) {
|
|
7147
|
-
return false;
|
|
7148
|
-
}
|
|
7149
|
-
|
|
7150
|
-
state.negated = true;
|
|
7151
|
-
state.start++;
|
|
7152
|
-
return true;
|
|
7153
|
-
};
|
|
7154
|
-
|
|
7155
|
-
const increment = type => {
|
|
7156
|
-
state[type]++;
|
|
7157
|
-
stack.push(type);
|
|
7158
|
-
};
|
|
7159
|
-
|
|
7160
|
-
const decrement = type => {
|
|
7161
|
-
state[type]--;
|
|
7162
|
-
stack.pop();
|
|
7163
|
-
};
|
|
7164
|
-
|
|
7165
|
-
/**
|
|
7166
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
7167
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
7168
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
7169
|
-
* characters are plain text. This improves performance and simplifies
|
|
7170
|
-
* lookbehinds.
|
|
7171
|
-
*/
|
|
7172
|
-
|
|
7173
|
-
const push = tok => {
|
|
7174
|
-
if (prev.type === 'globstar') {
|
|
7175
|
-
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
7176
|
-
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
7177
|
-
|
|
7178
|
-
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
7179
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
7180
|
-
prev.type = 'star';
|
|
7181
|
-
prev.value = '*';
|
|
7182
|
-
prev.output = star;
|
|
7183
|
-
state.output += prev.output;
|
|
7184
|
-
}
|
|
7185
|
-
}
|
|
7186
|
-
|
|
7187
|
-
if (extglobs.length && tok.type !== 'paren') {
|
|
7188
|
-
extglobs[extglobs.length - 1].inner += tok.value;
|
|
7189
|
-
}
|
|
7190
|
-
|
|
7191
|
-
if (tok.value || tok.output) append(tok);
|
|
7192
|
-
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
7193
|
-
prev.output = (prev.output || prev.value) + tok.value;
|
|
7194
|
-
prev.value += tok.value;
|
|
7195
|
-
return;
|
|
7196
|
-
}
|
|
7197
|
-
|
|
7198
|
-
tok.prev = prev;
|
|
7199
|
-
tokens.push(tok);
|
|
7200
|
-
prev = tok;
|
|
7201
|
-
};
|
|
7202
|
-
|
|
7203
|
-
const extglobOpen = (type, value) => {
|
|
7204
|
-
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
7205
|
-
|
|
7206
|
-
token.prev = prev;
|
|
7207
|
-
token.parens = state.parens;
|
|
7208
|
-
token.output = state.output;
|
|
7209
|
-
const output = (opts.capture ? '(' : '') + token.open;
|
|
7210
|
-
|
|
7211
|
-
increment('parens');
|
|
7212
|
-
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
7213
|
-
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
7214
|
-
extglobs.push(token);
|
|
7215
|
-
};
|
|
7216
|
-
|
|
7217
|
-
const extglobClose = token => {
|
|
7218
|
-
let output = token.close + (opts.capture ? ')' : '');
|
|
7219
|
-
let rest;
|
|
7220
|
-
|
|
7221
|
-
if (token.type === 'negate') {
|
|
7222
|
-
let extglobStar = star;
|
|
7223
|
-
|
|
7224
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
7225
|
-
extglobStar = globstar(opts);
|
|
7226
|
-
}
|
|
7227
|
-
|
|
7228
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
7229
|
-
output = token.close = `)$))${extglobStar}`;
|
|
7230
|
-
}
|
|
7231
|
-
|
|
7232
|
-
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
7233
|
-
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
7234
|
-
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
7235
|
-
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
7236
|
-
//
|
|
7237
|
-
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
7238
|
-
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
7239
|
-
|
|
7240
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
7241
|
-
}
|
|
7242
|
-
|
|
7243
|
-
if (token.prev.type === 'bos') {
|
|
7244
|
-
state.negatedExtglob = true;
|
|
7245
|
-
}
|
|
7246
|
-
}
|
|
7247
|
-
|
|
7248
|
-
push({ type: 'paren', extglob: true, value, output });
|
|
7249
|
-
decrement('parens');
|
|
7250
|
-
};
|
|
7251
|
-
|
|
7252
|
-
/**
|
|
7253
|
-
* Fast paths
|
|
7254
|
-
*/
|
|
7255
|
-
|
|
7256
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
7257
|
-
let backslashes = false;
|
|
7258
|
-
|
|
7259
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
7260
|
-
if (first === '\\') {
|
|
7261
|
-
backslashes = true;
|
|
7262
|
-
return m;
|
|
7263
|
-
}
|
|
7264
|
-
|
|
7265
|
-
if (first === '?') {
|
|
7266
|
-
if (esc) {
|
|
7267
|
-
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
7268
|
-
}
|
|
7269
|
-
if (index === 0) {
|
|
7270
|
-
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
7271
|
-
}
|
|
7272
|
-
return QMARK.repeat(chars.length);
|
|
7273
|
-
}
|
|
7274
|
-
|
|
7275
|
-
if (first === '.') {
|
|
7276
|
-
return DOT_LITERAL.repeat(chars.length);
|
|
7277
|
-
}
|
|
7278
|
-
|
|
7279
|
-
if (first === '*') {
|
|
7280
|
-
if (esc) {
|
|
7281
|
-
return esc + first + (rest ? star : '');
|
|
7282
|
-
}
|
|
7283
|
-
return star;
|
|
7284
|
-
}
|
|
7285
|
-
return esc ? m : `\\${m}`;
|
|
7286
|
-
});
|
|
7287
|
-
|
|
7288
|
-
if (backslashes === true) {
|
|
7289
|
-
if (opts.unescape === true) {
|
|
7290
|
-
output = output.replace(/\\/g, '');
|
|
7291
|
-
} else {
|
|
7292
|
-
output = output.replace(/\\+/g, m => {
|
|
7293
|
-
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
7294
|
-
});
|
|
7295
|
-
}
|
|
7296
|
-
}
|
|
7297
|
-
|
|
7298
|
-
if (output === input && opts.contains === true) {
|
|
7299
|
-
state.output = input;
|
|
7300
|
-
return state;
|
|
7301
|
-
}
|
|
7302
|
-
|
|
7303
|
-
state.output = utils.wrapOutput(output, state, options);
|
|
7304
|
-
return state;
|
|
7305
|
-
}
|
|
7306
|
-
|
|
7307
|
-
/**
|
|
7308
|
-
* Tokenize input until we reach end-of-string
|
|
7309
|
-
*/
|
|
7310
|
-
|
|
7311
|
-
while (!eos()) {
|
|
7312
|
-
value = advance();
|
|
7313
|
-
|
|
7314
|
-
if (value === '\u0000') {
|
|
7315
|
-
continue;
|
|
7316
|
-
}
|
|
7317
|
-
|
|
7318
|
-
/**
|
|
7319
|
-
* Escaped characters
|
|
7320
|
-
*/
|
|
7321
|
-
|
|
7322
|
-
if (value === '\\') {
|
|
7323
|
-
const next = peek();
|
|
7324
|
-
|
|
7325
|
-
if (next === '/' && opts.bash !== true) {
|
|
7326
|
-
continue;
|
|
7327
|
-
}
|
|
7328
|
-
|
|
7329
|
-
if (next === '.' || next === ';') {
|
|
7330
|
-
continue;
|
|
7331
|
-
}
|
|
7332
|
-
|
|
7333
|
-
if (!next) {
|
|
7334
|
-
value += '\\';
|
|
7335
|
-
push({ type: 'text', value });
|
|
7336
|
-
continue;
|
|
7337
|
-
}
|
|
7338
|
-
|
|
7339
|
-
// collapse slashes to reduce potential for exploits
|
|
7340
|
-
const match = /^\\+/.exec(remaining());
|
|
7341
|
-
let slashes = 0;
|
|
7342
|
-
|
|
7343
|
-
if (match && match[0].length > 2) {
|
|
7344
|
-
slashes = match[0].length;
|
|
7345
|
-
state.index += slashes;
|
|
7346
|
-
if (slashes % 2 !== 0) {
|
|
7347
|
-
value += '\\';
|
|
7348
|
-
}
|
|
7349
|
-
}
|
|
7350
|
-
|
|
7351
|
-
if (opts.unescape === true) {
|
|
7352
|
-
value = advance();
|
|
7353
|
-
} else {
|
|
7354
|
-
value += advance();
|
|
7355
|
-
}
|
|
7356
|
-
|
|
7357
|
-
if (state.brackets === 0) {
|
|
7358
|
-
push({ type: 'text', value });
|
|
7359
|
-
continue;
|
|
7360
|
-
}
|
|
7361
|
-
}
|
|
7362
|
-
|
|
7363
|
-
/**
|
|
7364
|
-
* If we're inside a regex character class, continue
|
|
7365
|
-
* until we reach the closing bracket.
|
|
7366
|
-
*/
|
|
7367
|
-
|
|
7368
|
-
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
7369
|
-
if (opts.posix !== false && value === ':') {
|
|
7370
|
-
const inner = prev.value.slice(1);
|
|
7371
|
-
if (inner.includes('[')) {
|
|
7372
|
-
prev.posix = true;
|
|
7373
|
-
|
|
7374
|
-
if (inner.includes(':')) {
|
|
7375
|
-
const idx = prev.value.lastIndexOf('[');
|
|
7376
|
-
const pre = prev.value.slice(0, idx);
|
|
7377
|
-
const rest = prev.value.slice(idx + 2);
|
|
7378
|
-
const posix = POSIX_REGEX_SOURCE[rest];
|
|
7379
|
-
if (posix) {
|
|
7380
|
-
prev.value = pre + posix;
|
|
7381
|
-
state.backtrack = true;
|
|
7382
|
-
advance();
|
|
7383
|
-
|
|
7384
|
-
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
7385
|
-
bos.output = ONE_CHAR;
|
|
7386
|
-
}
|
|
7387
|
-
continue;
|
|
7388
|
-
}
|
|
7389
|
-
}
|
|
7390
|
-
}
|
|
7391
|
-
}
|
|
7392
|
-
|
|
7393
|
-
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
7394
|
-
value = `\\${value}`;
|
|
7395
|
-
}
|
|
7396
|
-
|
|
7397
|
-
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
7398
|
-
value = `\\${value}`;
|
|
7399
|
-
}
|
|
7400
|
-
|
|
7401
|
-
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
7402
|
-
value = '^';
|
|
7403
|
-
}
|
|
7404
|
-
|
|
7405
|
-
prev.value += value;
|
|
7406
|
-
append({ value });
|
|
7407
|
-
continue;
|
|
7408
|
-
}
|
|
7409
|
-
|
|
7410
|
-
/**
|
|
7411
|
-
* If we're inside a quoted string, continue
|
|
7412
|
-
* until we reach the closing double quote.
|
|
7413
|
-
*/
|
|
7414
|
-
|
|
7415
|
-
if (state.quotes === 1 && value !== '"') {
|
|
7416
|
-
value = utils.escapeRegex(value);
|
|
7417
|
-
prev.value += value;
|
|
7418
|
-
append({ value });
|
|
7419
|
-
continue;
|
|
7420
|
-
}
|
|
7421
|
-
|
|
7422
|
-
/**
|
|
7423
|
-
* Double quotes
|
|
7424
|
-
*/
|
|
7425
|
-
|
|
7426
|
-
if (value === '"') {
|
|
7427
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
7428
|
-
if (opts.keepQuotes === true) {
|
|
7429
|
-
push({ type: 'text', value });
|
|
7430
|
-
}
|
|
7431
|
-
continue;
|
|
7432
|
-
}
|
|
7433
|
-
|
|
7434
|
-
/**
|
|
7435
|
-
* Parentheses
|
|
7436
|
-
*/
|
|
7437
|
-
|
|
7438
|
-
if (value === '(') {
|
|
7439
|
-
increment('parens');
|
|
7440
|
-
push({ type: 'paren', value });
|
|
7441
|
-
continue;
|
|
7442
|
-
}
|
|
7443
|
-
|
|
7444
|
-
if (value === ')') {
|
|
7445
|
-
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
7446
|
-
throw new SyntaxError(syntaxError('opening', '('));
|
|
7447
|
-
}
|
|
7448
|
-
|
|
7449
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
7450
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
7451
|
-
extglobClose(extglobs.pop());
|
|
7452
|
-
continue;
|
|
7453
|
-
}
|
|
7454
|
-
|
|
7455
|
-
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
7456
|
-
decrement('parens');
|
|
7457
|
-
continue;
|
|
7458
|
-
}
|
|
7459
|
-
|
|
7460
|
-
/**
|
|
7461
|
-
* Square brackets
|
|
7462
|
-
*/
|
|
7463
|
-
|
|
7464
|
-
if (value === '[') {
|
|
7465
|
-
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
7466
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
7467
|
-
throw new SyntaxError(syntaxError('closing', ']'));
|
|
7468
|
-
}
|
|
7469
|
-
|
|
7470
|
-
value = `\\${value}`;
|
|
7471
|
-
} else {
|
|
7472
|
-
increment('brackets');
|
|
7473
|
-
}
|
|
7474
|
-
|
|
7475
|
-
push({ type: 'bracket', value });
|
|
7476
|
-
continue;
|
|
7477
|
-
}
|
|
7478
|
-
|
|
7479
|
-
if (value === ']') {
|
|
7480
|
-
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
7481
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
7482
|
-
continue;
|
|
7483
|
-
}
|
|
7484
|
-
|
|
7485
|
-
if (state.brackets === 0) {
|
|
7486
|
-
if (opts.strictBrackets === true) {
|
|
7487
|
-
throw new SyntaxError(syntaxError('opening', '['));
|
|
7488
|
-
}
|
|
7489
|
-
|
|
7490
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
7491
|
-
continue;
|
|
7492
|
-
}
|
|
7493
|
-
|
|
7494
|
-
decrement('brackets');
|
|
7495
|
-
|
|
7496
|
-
const prevValue = prev.value.slice(1);
|
|
7497
|
-
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
7498
|
-
value = `/${value}`;
|
|
7499
|
-
}
|
|
7500
|
-
|
|
7501
|
-
prev.value += value;
|
|
7502
|
-
append({ value });
|
|
7503
|
-
|
|
7504
|
-
// when literal brackets are explicitly disabled
|
|
7505
|
-
// assume we should match with a regex character class
|
|
7506
|
-
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
7507
|
-
continue;
|
|
7508
|
-
}
|
|
7509
|
-
|
|
7510
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
7511
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
7512
|
-
|
|
7513
|
-
// when literal brackets are explicitly enabled
|
|
7514
|
-
// assume we should escape the brackets to match literal characters
|
|
7515
|
-
if (opts.literalBrackets === true) {
|
|
7516
|
-
state.output += escaped;
|
|
7517
|
-
prev.value = escaped;
|
|
7518
|
-
continue;
|
|
7519
|
-
}
|
|
7520
|
-
|
|
7521
|
-
// when the user specifies nothing, try to match both
|
|
7522
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
7523
|
-
state.output += prev.value;
|
|
7524
|
-
continue;
|
|
7525
|
-
}
|
|
7526
|
-
|
|
7527
|
-
/**
|
|
7528
|
-
* Braces
|
|
7529
|
-
*/
|
|
7530
|
-
|
|
7531
|
-
if (value === '{' && opts.nobrace !== true) {
|
|
7532
|
-
increment('braces');
|
|
7533
|
-
|
|
7534
|
-
const open = {
|
|
7535
|
-
type: 'brace',
|
|
7536
|
-
value,
|
|
7537
|
-
output: '(',
|
|
7538
|
-
outputIndex: state.output.length,
|
|
7539
|
-
tokensIndex: state.tokens.length
|
|
7540
|
-
};
|
|
7541
|
-
|
|
7542
|
-
braces.push(open);
|
|
7543
|
-
push(open);
|
|
7544
|
-
continue;
|
|
7545
|
-
}
|
|
7546
|
-
|
|
7547
|
-
if (value === '}') {
|
|
7548
|
-
const brace = braces[braces.length - 1];
|
|
7549
|
-
|
|
7550
|
-
if (opts.nobrace === true || !brace) {
|
|
7551
|
-
push({ type: 'text', value, output: value });
|
|
7552
|
-
continue;
|
|
7553
|
-
}
|
|
7554
|
-
|
|
7555
|
-
let output = ')';
|
|
7556
|
-
|
|
7557
|
-
if (brace.dots === true) {
|
|
7558
|
-
const arr = tokens.slice();
|
|
7559
|
-
const range = [];
|
|
7560
|
-
|
|
7561
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
7562
|
-
tokens.pop();
|
|
7563
|
-
if (arr[i].type === 'brace') {
|
|
7564
|
-
break;
|
|
7565
|
-
}
|
|
7566
|
-
if (arr[i].type !== 'dots') {
|
|
7567
|
-
range.unshift(arr[i].value);
|
|
7568
|
-
}
|
|
7569
|
-
}
|
|
7570
|
-
|
|
7571
|
-
output = expandRange(range, opts);
|
|
7572
|
-
state.backtrack = true;
|
|
7573
|
-
}
|
|
7574
|
-
|
|
7575
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
7576
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
7577
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
7578
|
-
brace.value = brace.output = '\\{';
|
|
7579
|
-
value = output = '\\}';
|
|
7580
|
-
state.output = out;
|
|
7581
|
-
for (const t of toks) {
|
|
7582
|
-
state.output += (t.output || t.value);
|
|
7583
|
-
}
|
|
7584
|
-
}
|
|
7585
|
-
|
|
7586
|
-
push({ type: 'brace', value, output });
|
|
7587
|
-
decrement('braces');
|
|
7588
|
-
braces.pop();
|
|
7589
|
-
continue;
|
|
7590
|
-
}
|
|
7591
|
-
|
|
7592
|
-
/**
|
|
7593
|
-
* Pipes
|
|
7594
|
-
*/
|
|
7595
|
-
|
|
7596
|
-
if (value === '|') {
|
|
7597
|
-
if (extglobs.length > 0) {
|
|
7598
|
-
extglobs[extglobs.length - 1].conditions++;
|
|
7599
|
-
}
|
|
7600
|
-
push({ type: 'text', value });
|
|
7601
|
-
continue;
|
|
7602
|
-
}
|
|
7603
|
-
|
|
7604
|
-
/**
|
|
7605
|
-
* Commas
|
|
7606
|
-
*/
|
|
7607
|
-
|
|
7608
|
-
if (value === ',') {
|
|
7609
|
-
let output = value;
|
|
7610
|
-
|
|
7611
|
-
const brace = braces[braces.length - 1];
|
|
7612
|
-
if (brace && stack[stack.length - 1] === 'braces') {
|
|
7613
|
-
brace.comma = true;
|
|
7614
|
-
output = '|';
|
|
7615
|
-
}
|
|
7616
|
-
|
|
7617
|
-
push({ type: 'comma', value, output });
|
|
7618
|
-
continue;
|
|
7619
|
-
}
|
|
7620
|
-
|
|
7621
|
-
/**
|
|
7622
|
-
* Slashes
|
|
7623
|
-
*/
|
|
7624
|
-
|
|
7625
|
-
if (value === '/') {
|
|
7626
|
-
// if the beginning of the glob is "./", advance the start
|
|
7627
|
-
// to the current index, and don't add the "./" characters
|
|
7628
|
-
// to the state. This greatly simplifies lookbehinds when
|
|
7629
|
-
// checking for BOS characters like "!" and "." (not "./")
|
|
7630
|
-
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
7631
|
-
state.start = state.index + 1;
|
|
7632
|
-
state.consumed = '';
|
|
7633
|
-
state.output = '';
|
|
7634
|
-
tokens.pop();
|
|
7635
|
-
prev = bos; // reset "prev" to the first token
|
|
7636
|
-
continue;
|
|
7637
|
-
}
|
|
7638
|
-
|
|
7639
|
-
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
7640
|
-
continue;
|
|
7641
|
-
}
|
|
7642
|
-
|
|
7643
|
-
/**
|
|
7644
|
-
* Dots
|
|
7645
|
-
*/
|
|
7646
|
-
|
|
7647
|
-
if (value === '.') {
|
|
7648
|
-
if (state.braces > 0 && prev.type === 'dot') {
|
|
7649
|
-
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
7650
|
-
const brace = braces[braces.length - 1];
|
|
7651
|
-
prev.type = 'dots';
|
|
7652
|
-
prev.output += value;
|
|
7653
|
-
prev.value += value;
|
|
7654
|
-
brace.dots = true;
|
|
7655
|
-
continue;
|
|
7656
|
-
}
|
|
7657
|
-
|
|
7658
|
-
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
7659
|
-
push({ type: 'text', value, output: DOT_LITERAL });
|
|
7660
|
-
continue;
|
|
7661
|
-
}
|
|
7662
|
-
|
|
7663
|
-
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
7664
|
-
continue;
|
|
7665
|
-
}
|
|
7666
|
-
|
|
7667
|
-
/**
|
|
7668
|
-
* Question marks
|
|
7669
|
-
*/
|
|
7670
|
-
|
|
7671
|
-
if (value === '?') {
|
|
7672
|
-
const isGroup = prev && prev.value === '(';
|
|
7673
|
-
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
7674
|
-
extglobOpen('qmark', value);
|
|
7675
|
-
continue;
|
|
7676
|
-
}
|
|
7677
|
-
|
|
7678
|
-
if (prev && prev.type === 'paren') {
|
|
7679
|
-
const next = peek();
|
|
7680
|
-
let output = value;
|
|
7681
|
-
|
|
7682
|
-
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
7683
|
-
output = `\\${value}`;
|
|
7684
|
-
}
|
|
7685
|
-
|
|
7686
|
-
push({ type: 'text', value, output });
|
|
7687
|
-
continue;
|
|
7688
|
-
}
|
|
7689
|
-
|
|
7690
|
-
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
7691
|
-
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
7692
|
-
continue;
|
|
7693
|
-
}
|
|
7694
|
-
|
|
7695
|
-
push({ type: 'qmark', value, output: QMARK });
|
|
7696
|
-
continue;
|
|
7697
|
-
}
|
|
7698
|
-
|
|
7699
|
-
/**
|
|
7700
|
-
* Exclamation
|
|
7701
|
-
*/
|
|
7702
|
-
|
|
7703
|
-
if (value === '!') {
|
|
7704
|
-
if (opts.noextglob !== true && peek() === '(') {
|
|
7705
|
-
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
7706
|
-
extglobOpen('negate', value);
|
|
7707
|
-
continue;
|
|
7708
|
-
}
|
|
7709
|
-
}
|
|
7710
|
-
|
|
7711
|
-
if (opts.nonegate !== true && state.index === 0) {
|
|
7712
|
-
negate();
|
|
7713
|
-
continue;
|
|
7714
|
-
}
|
|
7715
|
-
}
|
|
7716
|
-
|
|
7717
|
-
/**
|
|
7718
|
-
* Plus
|
|
7719
|
-
*/
|
|
7720
|
-
|
|
7721
|
-
if (value === '+') {
|
|
7722
|
-
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
7723
|
-
extglobOpen('plus', value);
|
|
7724
|
-
continue;
|
|
7725
|
-
}
|
|
7726
|
-
|
|
7727
|
-
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
7728
|
-
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
7729
|
-
continue;
|
|
7730
|
-
}
|
|
7731
|
-
|
|
7732
|
-
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
7733
|
-
push({ type: 'plus', value });
|
|
7734
|
-
continue;
|
|
7735
|
-
}
|
|
7736
|
-
|
|
7737
|
-
push({ type: 'plus', value: PLUS_LITERAL });
|
|
7738
|
-
continue;
|
|
7739
|
-
}
|
|
7740
|
-
|
|
7741
|
-
/**
|
|
7742
|
-
* Plain text
|
|
7743
|
-
*/
|
|
7744
|
-
|
|
7745
|
-
if (value === '@') {
|
|
7746
|
-
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
7747
|
-
push({ type: 'at', extglob: true, value, output: '' });
|
|
7748
|
-
continue;
|
|
7749
|
-
}
|
|
7750
|
-
|
|
7751
|
-
push({ type: 'text', value });
|
|
7752
|
-
continue;
|
|
7753
|
-
}
|
|
7754
|
-
|
|
7755
|
-
/**
|
|
7756
|
-
* Plain text
|
|
7757
|
-
*/
|
|
7758
|
-
|
|
7759
|
-
if (value !== '*') {
|
|
7760
|
-
if (value === '$' || value === '^') {
|
|
7761
|
-
value = `\\${value}`;
|
|
7762
|
-
}
|
|
7763
|
-
|
|
7764
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
7765
|
-
if (match) {
|
|
7766
|
-
value += match[0];
|
|
7767
|
-
state.index += match[0].length;
|
|
7768
|
-
}
|
|
7769
|
-
|
|
7770
|
-
push({ type: 'text', value });
|
|
7771
|
-
continue;
|
|
7772
|
-
}
|
|
7773
|
-
|
|
7774
|
-
/**
|
|
7775
|
-
* Stars
|
|
7776
|
-
*/
|
|
7777
|
-
|
|
7778
|
-
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
7779
|
-
prev.type = 'star';
|
|
7780
|
-
prev.star = true;
|
|
7781
|
-
prev.value += value;
|
|
7782
|
-
prev.output = star;
|
|
7783
|
-
state.backtrack = true;
|
|
7784
|
-
state.globstar = true;
|
|
7785
|
-
consume(value);
|
|
7786
|
-
continue;
|
|
7787
|
-
}
|
|
7788
|
-
|
|
7789
|
-
let rest = remaining();
|
|
7790
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
7791
|
-
extglobOpen('star', value);
|
|
7792
|
-
continue;
|
|
7793
|
-
}
|
|
7794
|
-
|
|
7795
|
-
if (prev.type === 'star') {
|
|
7796
|
-
if (opts.noglobstar === true) {
|
|
7797
|
-
consume(value);
|
|
7798
|
-
continue;
|
|
7799
|
-
}
|
|
7800
|
-
|
|
7801
|
-
const prior = prev.prev;
|
|
7802
|
-
const before = prior.prev;
|
|
7803
|
-
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
7804
|
-
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
7805
|
-
|
|
7806
|
-
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
7807
|
-
push({ type: 'star', value, output: '' });
|
|
7808
|
-
continue;
|
|
7809
|
-
}
|
|
7810
|
-
|
|
7811
|
-
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
7812
|
-
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
7813
|
-
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
7814
|
-
push({ type: 'star', value, output: '' });
|
|
7815
|
-
continue;
|
|
7816
|
-
}
|
|
7817
|
-
|
|
7818
|
-
// strip consecutive `/**/`
|
|
7819
|
-
while (rest.slice(0, 3) === '/**') {
|
|
7820
|
-
const after = input[state.index + 4];
|
|
7821
|
-
if (after && after !== '/') {
|
|
7822
|
-
break;
|
|
7823
|
-
}
|
|
7824
|
-
rest = rest.slice(3);
|
|
7825
|
-
consume('/**', 3);
|
|
7826
|
-
}
|
|
7827
|
-
|
|
7828
|
-
if (prior.type === 'bos' && eos()) {
|
|
7829
|
-
prev.type = 'globstar';
|
|
7830
|
-
prev.value += value;
|
|
7831
|
-
prev.output = globstar(opts);
|
|
7832
|
-
state.output = prev.output;
|
|
7833
|
-
state.globstar = true;
|
|
7834
|
-
consume(value);
|
|
7835
|
-
continue;
|
|
7836
|
-
}
|
|
7837
|
-
|
|
7838
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
7839
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7840
|
-
prior.output = `(?:${prior.output}`;
|
|
7841
|
-
|
|
7842
|
-
prev.type = 'globstar';
|
|
7843
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
7844
|
-
prev.value += value;
|
|
7845
|
-
state.globstar = true;
|
|
7846
|
-
state.output += prior.output + prev.output;
|
|
7847
|
-
consume(value);
|
|
7848
|
-
continue;
|
|
7849
|
-
}
|
|
7850
|
-
|
|
7851
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
7852
|
-
const end = rest[1] !== void 0 ? '|$' : '';
|
|
7853
|
-
|
|
7854
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7855
|
-
prior.output = `(?:${prior.output}`;
|
|
7856
|
-
|
|
7857
|
-
prev.type = 'globstar';
|
|
7858
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
7859
|
-
prev.value += value;
|
|
7860
|
-
|
|
7861
|
-
state.output += prior.output + prev.output;
|
|
7862
|
-
state.globstar = true;
|
|
7863
|
-
|
|
7864
|
-
consume(value + advance());
|
|
7865
|
-
|
|
7866
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
7867
|
-
continue;
|
|
7868
|
-
}
|
|
7869
|
-
|
|
7870
|
-
if (prior.type === 'bos' && rest[0] === '/') {
|
|
7871
|
-
prev.type = 'globstar';
|
|
7872
|
-
prev.value += value;
|
|
7873
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
7874
|
-
state.output = prev.output;
|
|
7875
|
-
state.globstar = true;
|
|
7876
|
-
consume(value + advance());
|
|
7877
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
7878
|
-
continue;
|
|
7879
|
-
}
|
|
7880
|
-
|
|
7881
|
-
// remove single star from output
|
|
7882
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
7883
|
-
|
|
7884
|
-
// reset previous token to globstar
|
|
7885
|
-
prev.type = 'globstar';
|
|
7886
|
-
prev.output = globstar(opts);
|
|
7887
|
-
prev.value += value;
|
|
7888
|
-
|
|
7889
|
-
// reset output with globstar
|
|
7890
|
-
state.output += prev.output;
|
|
7891
|
-
state.globstar = true;
|
|
7892
|
-
consume(value);
|
|
7893
|
-
continue;
|
|
7894
|
-
}
|
|
7895
|
-
|
|
7896
|
-
const token = { type: 'star', value, output: star };
|
|
7897
|
-
|
|
7898
|
-
if (opts.bash === true) {
|
|
7899
|
-
token.output = '.*?';
|
|
7900
|
-
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
7901
|
-
token.output = nodot + token.output;
|
|
7902
|
-
}
|
|
7903
|
-
push(token);
|
|
7904
|
-
continue;
|
|
7905
|
-
}
|
|
7906
|
-
|
|
7907
|
-
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
7908
|
-
token.output = value;
|
|
7909
|
-
push(token);
|
|
7910
|
-
continue;
|
|
7911
|
-
}
|
|
7912
|
-
|
|
7913
|
-
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
7914
|
-
if (prev.type === 'dot') {
|
|
7915
|
-
state.output += NO_DOT_SLASH;
|
|
7916
|
-
prev.output += NO_DOT_SLASH;
|
|
7917
|
-
|
|
7918
|
-
} else if (opts.dot === true) {
|
|
7919
|
-
state.output += NO_DOTS_SLASH;
|
|
7920
|
-
prev.output += NO_DOTS_SLASH;
|
|
7921
|
-
|
|
7922
|
-
} else {
|
|
7923
|
-
state.output += nodot;
|
|
7924
|
-
prev.output += nodot;
|
|
7925
|
-
}
|
|
7926
|
-
|
|
7927
|
-
if (peek() !== '*') {
|
|
7928
|
-
state.output += ONE_CHAR;
|
|
7929
|
-
prev.output += ONE_CHAR;
|
|
7930
|
-
}
|
|
7931
|
-
}
|
|
7932
|
-
|
|
7933
|
-
push(token);
|
|
7934
|
-
}
|
|
7935
|
-
|
|
7936
|
-
while (state.brackets > 0) {
|
|
7937
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
7938
|
-
state.output = utils.escapeLast(state.output, '[');
|
|
7939
|
-
decrement('brackets');
|
|
7940
|
-
}
|
|
7941
|
-
|
|
7942
|
-
while (state.parens > 0) {
|
|
7943
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
7944
|
-
state.output = utils.escapeLast(state.output, '(');
|
|
7945
|
-
decrement('parens');
|
|
7946
|
-
}
|
|
7947
|
-
|
|
7948
|
-
while (state.braces > 0) {
|
|
7949
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
7950
|
-
state.output = utils.escapeLast(state.output, '{');
|
|
7951
|
-
decrement('braces');
|
|
7952
|
-
}
|
|
7953
|
-
|
|
7954
|
-
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
7955
|
-
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
7956
|
-
}
|
|
7957
|
-
|
|
7958
|
-
// rebuild the output if we had to backtrack at any point
|
|
7959
|
-
if (state.backtrack === true) {
|
|
7960
|
-
state.output = '';
|
|
7961
|
-
|
|
7962
|
-
for (const token of state.tokens) {
|
|
7963
|
-
state.output += token.output != null ? token.output : token.value;
|
|
7964
|
-
|
|
7965
|
-
if (token.suffix) {
|
|
7966
|
-
state.output += token.suffix;
|
|
7967
|
-
}
|
|
7968
|
-
}
|
|
7969
|
-
}
|
|
7970
|
-
|
|
7971
|
-
return state;
|
|
7972
|
-
};
|
|
7973
|
-
|
|
7974
|
-
/**
|
|
7975
|
-
* Fast paths for creating regular expressions for common glob patterns.
|
|
7976
|
-
* This can significantly speed up processing and has very little downside
|
|
7977
|
-
* impact when none of the fast paths match.
|
|
7978
|
-
*/
|
|
7979
|
-
|
|
7980
|
-
parse.fastpaths = (input, options) => {
|
|
7981
|
-
const opts = { ...options };
|
|
7982
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7983
|
-
const len = input.length;
|
|
7984
|
-
if (len > max) {
|
|
7985
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
7986
|
-
}
|
|
7987
|
-
|
|
7988
|
-
input = REPLACEMENTS[input] || input;
|
|
7989
|
-
|
|
7990
|
-
// create constants based on platform, for windows or posix
|
|
7991
|
-
const {
|
|
7992
|
-
DOT_LITERAL,
|
|
7993
|
-
SLASH_LITERAL,
|
|
7994
|
-
ONE_CHAR,
|
|
7995
|
-
DOTS_SLASH,
|
|
7996
|
-
NO_DOT,
|
|
7997
|
-
NO_DOTS,
|
|
7998
|
-
NO_DOTS_SLASH,
|
|
7999
|
-
STAR,
|
|
8000
|
-
START_ANCHOR
|
|
8001
|
-
} = constants.globChars(opts.windows);
|
|
8002
|
-
|
|
8003
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
8004
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
8005
|
-
const capture = opts.capture ? '' : '?:';
|
|
8006
|
-
const state = { negated: false, prefix: '' };
|
|
8007
|
-
let star = opts.bash === true ? '.*?' : STAR;
|
|
8008
|
-
|
|
8009
|
-
if (opts.capture) {
|
|
8010
|
-
star = `(${star})`;
|
|
8011
|
-
}
|
|
8012
|
-
|
|
8013
|
-
const globstar = opts => {
|
|
8014
|
-
if (opts.noglobstar === true) return star;
|
|
8015
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
8016
|
-
};
|
|
8017
|
-
|
|
8018
|
-
const create = str => {
|
|
8019
|
-
switch (str) {
|
|
8020
|
-
case '*':
|
|
8021
|
-
return `${nodot}${ONE_CHAR}${star}`;
|
|
8022
|
-
|
|
8023
|
-
case '.*':
|
|
8024
|
-
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
8025
|
-
|
|
8026
|
-
case '*.*':
|
|
8027
|
-
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
8028
|
-
|
|
8029
|
-
case '*/*':
|
|
8030
|
-
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
8031
|
-
|
|
8032
|
-
case '**':
|
|
8033
|
-
return nodot + globstar(opts);
|
|
8034
|
-
|
|
8035
|
-
case '**/*':
|
|
8036
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
8037
|
-
|
|
8038
|
-
case '**/*.*':
|
|
8039
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
8040
|
-
|
|
8041
|
-
case '**/.*':
|
|
8042
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
8043
|
-
|
|
8044
|
-
default: {
|
|
8045
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
8046
|
-
if (!match) return;
|
|
8047
|
-
|
|
8048
|
-
const source = create(match[1]);
|
|
8049
|
-
if (!source) return;
|
|
8050
|
-
|
|
8051
|
-
return source + DOT_LITERAL + match[2];
|
|
8052
|
-
}
|
|
8053
|
-
}
|
|
8054
|
-
};
|
|
8055
|
-
|
|
8056
|
-
const output = utils.removePrefix(input, state);
|
|
8057
|
-
let source = create(output);
|
|
8058
|
-
|
|
8059
|
-
if (source && opts.strictSlashes !== true) {
|
|
8060
|
-
source += `${SLASH_LITERAL}?`;
|
|
8061
|
-
}
|
|
8062
|
-
|
|
8063
|
-
return source;
|
|
8064
|
-
};
|
|
8065
|
-
|
|
8066
|
-
parse_1 = parse;
|
|
8067
|
-
return parse_1;
|
|
8068
|
-
}
|
|
8069
|
-
|
|
8070
|
-
var picomatch_1$1;
|
|
8071
|
-
var hasRequiredPicomatch$1;
|
|
8072
|
-
|
|
8073
|
-
function requirePicomatch$1 () {
|
|
8074
|
-
if (hasRequiredPicomatch$1) return picomatch_1$1;
|
|
8075
|
-
hasRequiredPicomatch$1 = 1;
|
|
8076
|
-
|
|
8077
|
-
const scan = requireScan();
|
|
8078
|
-
const parse = requireParse();
|
|
8079
|
-
const utils = requireUtils();
|
|
8080
|
-
const constants = requireConstants();
|
|
8081
|
-
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
8082
|
-
|
|
8083
|
-
/**
|
|
8084
|
-
* Creates a matcher function from one or more glob patterns. The
|
|
8085
|
-
* returned function takes a string to match as its first argument,
|
|
8086
|
-
* and returns true if the string is a match. The returned matcher
|
|
8087
|
-
* function also takes a boolean as the second argument that, when true,
|
|
8088
|
-
* returns an object with additional information.
|
|
8089
|
-
*
|
|
8090
|
-
* ```js
|
|
8091
|
-
* const picomatch = require('picomatch');
|
|
8092
|
-
* // picomatch(glob[, options]);
|
|
8093
|
-
*
|
|
8094
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
8095
|
-
* console.log(isMatch('a.a')); //=> false
|
|
8096
|
-
* console.log(isMatch('a.b')); //=> true
|
|
8097
|
-
* ```
|
|
8098
|
-
* @name picomatch
|
|
8099
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
8100
|
-
* @param {Object=} `options`
|
|
8101
|
-
* @return {Function=} Returns a matcher function.
|
|
8102
|
-
* @api public
|
|
8103
|
-
*/
|
|
8104
|
-
|
|
8105
|
-
const picomatch = (glob, options, returnState = false) => {
|
|
8106
|
-
if (Array.isArray(glob)) {
|
|
8107
|
-
const fns = glob.map(input => picomatch(input, options, returnState));
|
|
8108
|
-
const arrayMatcher = str => {
|
|
8109
|
-
for (const isMatch of fns) {
|
|
8110
|
-
const state = isMatch(str);
|
|
8111
|
-
if (state) return state;
|
|
8112
|
-
}
|
|
8113
|
-
return false;
|
|
8114
|
-
};
|
|
8115
|
-
return arrayMatcher;
|
|
8116
|
-
}
|
|
8117
|
-
|
|
8118
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
8119
|
-
|
|
8120
|
-
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
8121
|
-
throw new TypeError('Expected pattern to be a non-empty string');
|
|
8122
|
-
}
|
|
8123
|
-
|
|
8124
|
-
const opts = options || {};
|
|
8125
|
-
const posix = opts.windows;
|
|
8126
|
-
const regex = isState
|
|
8127
|
-
? picomatch.compileRe(glob, options)
|
|
8128
|
-
: picomatch.makeRe(glob, options, false, true);
|
|
8129
|
-
|
|
8130
|
-
const state = regex.state;
|
|
8131
|
-
delete regex.state;
|
|
8132
|
-
|
|
8133
|
-
let isIgnored = () => false;
|
|
8134
|
-
if (opts.ignore) {
|
|
8135
|
-
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
8136
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
8137
|
-
}
|
|
8138
|
-
|
|
8139
|
-
const matcher = (input, returnObject = false) => {
|
|
8140
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
8141
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
8142
|
-
|
|
8143
|
-
if (typeof opts.onResult === 'function') {
|
|
8144
|
-
opts.onResult(result);
|
|
8145
|
-
}
|
|
8146
|
-
|
|
8147
|
-
if (isMatch === false) {
|
|
8148
|
-
result.isMatch = false;
|
|
8149
|
-
return returnObject ? result : false;
|
|
8150
|
-
}
|
|
8151
|
-
|
|
8152
|
-
if (isIgnored(input)) {
|
|
8153
|
-
if (typeof opts.onIgnore === 'function') {
|
|
8154
|
-
opts.onIgnore(result);
|
|
8155
|
-
}
|
|
8156
|
-
result.isMatch = false;
|
|
8157
|
-
return returnObject ? result : false;
|
|
8158
|
-
}
|
|
8159
|
-
|
|
8160
|
-
if (typeof opts.onMatch === 'function') {
|
|
8161
|
-
opts.onMatch(result);
|
|
8162
|
-
}
|
|
8163
|
-
return returnObject ? result : true;
|
|
8164
|
-
};
|
|
8165
|
-
|
|
8166
|
-
if (returnState) {
|
|
8167
|
-
matcher.state = state;
|
|
8168
|
-
}
|
|
8169
|
-
|
|
8170
|
-
return matcher;
|
|
8171
|
-
};
|
|
8172
|
-
|
|
8173
|
-
/**
|
|
8174
|
-
* Test `input` with the given `regex`. This is used by the main
|
|
8175
|
-
* `picomatch()` function to test the input string.
|
|
8176
|
-
*
|
|
8177
|
-
* ```js
|
|
8178
|
-
* const picomatch = require('picomatch');
|
|
8179
|
-
* // picomatch.test(input, regex[, options]);
|
|
8180
|
-
*
|
|
8181
|
-
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
8182
|
-
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
8183
|
-
* ```
|
|
8184
|
-
* @param {String} `input` String to test.
|
|
8185
|
-
* @param {RegExp} `regex`
|
|
8186
|
-
* @return {Object} Returns an object with matching info.
|
|
8187
|
-
* @api public
|
|
8188
|
-
*/
|
|
8189
|
-
|
|
8190
|
-
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
8191
|
-
if (typeof input !== 'string') {
|
|
8192
|
-
throw new TypeError('Expected input to be a string');
|
|
8193
|
-
}
|
|
8194
|
-
|
|
8195
|
-
if (input === '') {
|
|
8196
|
-
return { isMatch: false, output: '' };
|
|
8197
|
-
}
|
|
8198
|
-
|
|
8199
|
-
const opts = options || {};
|
|
8200
|
-
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
8201
|
-
let match = input === glob;
|
|
8202
|
-
let output = (match && format) ? format(input) : input;
|
|
8203
|
-
|
|
8204
|
-
if (match === false) {
|
|
8205
|
-
output = format ? format(input) : input;
|
|
8206
|
-
match = output === glob;
|
|
8207
|
-
}
|
|
8208
|
-
|
|
8209
|
-
if (match === false || opts.capture === true) {
|
|
8210
|
-
if (opts.matchBase === true || opts.basename === true) {
|
|
8211
|
-
match = picomatch.matchBase(input, regex, options, posix);
|
|
8212
|
-
} else {
|
|
8213
|
-
match = regex.exec(output);
|
|
8214
|
-
}
|
|
8215
|
-
}
|
|
8216
|
-
|
|
8217
|
-
return { isMatch: Boolean(match), match, output };
|
|
8218
|
-
};
|
|
8219
|
-
|
|
8220
|
-
/**
|
|
8221
|
-
* Match the basename of a filepath.
|
|
8222
|
-
*
|
|
8223
|
-
* ```js
|
|
8224
|
-
* const picomatch = require('picomatch');
|
|
8225
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
8226
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
8227
|
-
* ```
|
|
8228
|
-
* @param {String} `input` String to test.
|
|
8229
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
8230
|
-
* @return {Boolean}
|
|
8231
|
-
* @api public
|
|
8232
|
-
*/
|
|
8233
|
-
|
|
8234
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
8235
|
-
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
8236
|
-
return regex.test(utils.basename(input));
|
|
8237
|
-
};
|
|
8238
|
-
|
|
8239
|
-
/**
|
|
8240
|
-
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
8241
|
-
*
|
|
8242
|
-
* ```js
|
|
8243
|
-
* const picomatch = require('picomatch');
|
|
8244
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
8245
|
-
*
|
|
8246
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
8247
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
8248
|
-
* ```
|
|
8249
|
-
* @param {String|Array} str The string to test.
|
|
8250
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
8251
|
-
* @param {Object} [options] See available [options](#options).
|
|
8252
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
8253
|
-
* @api public
|
|
8254
|
-
*/
|
|
8255
|
-
|
|
8256
|
-
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
8257
|
-
|
|
8258
|
-
/**
|
|
8259
|
-
* Parse a glob pattern to create the source string for a regular
|
|
8260
|
-
* expression.
|
|
8261
|
-
*
|
|
8262
|
-
* ```js
|
|
8263
|
-
* const picomatch = require('picomatch');
|
|
8264
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
8265
|
-
* ```
|
|
8266
|
-
* @param {String} `pattern`
|
|
8267
|
-
* @param {Object} `options`
|
|
8268
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
8269
|
-
* @api public
|
|
8270
|
-
*/
|
|
8271
|
-
|
|
8272
|
-
picomatch.parse = (pattern, options) => {
|
|
8273
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
8274
|
-
return parse(pattern, { ...options, fastpaths: false });
|
|
8275
|
-
};
|
|
8276
|
-
|
|
8277
|
-
/**
|
|
8278
|
-
* Scan a glob pattern to separate the pattern into segments.
|
|
8279
|
-
*
|
|
8280
|
-
* ```js
|
|
8281
|
-
* const picomatch = require('picomatch');
|
|
8282
|
-
* // picomatch.scan(input[, options]);
|
|
8283
|
-
*
|
|
8284
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
8285
|
-
* console.log(result);
|
|
8286
|
-
* { prefix: '!./',
|
|
8287
|
-
* input: '!./foo/*.js',
|
|
8288
|
-
* start: 3,
|
|
8289
|
-
* base: 'foo',
|
|
8290
|
-
* glob: '*.js',
|
|
8291
|
-
* isBrace: false,
|
|
8292
|
-
* isBracket: false,
|
|
8293
|
-
* isGlob: true,
|
|
8294
|
-
* isExtglob: false,
|
|
8295
|
-
* isGlobstar: false,
|
|
8296
|
-
* negated: true }
|
|
8297
|
-
* ```
|
|
8298
|
-
* @param {String} `input` Glob pattern to scan.
|
|
8299
|
-
* @param {Object} `options`
|
|
8300
|
-
* @return {Object} Returns an object with
|
|
8301
|
-
* @api public
|
|
8302
|
-
*/
|
|
8303
|
-
|
|
8304
|
-
picomatch.scan = (input, options) => scan(input, options);
|
|
8305
|
-
|
|
8306
|
-
/**
|
|
8307
|
-
* Compile a regular expression from the `state` object returned by the
|
|
8308
|
-
* [parse()](#parse) method.
|
|
8309
|
-
*
|
|
8310
|
-
* @param {Object} `state`
|
|
8311
|
-
* @param {Object} `options`
|
|
8312
|
-
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
8313
|
-
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
8314
|
-
* @return {RegExp}
|
|
8315
|
-
* @api public
|
|
8316
|
-
*/
|
|
8317
|
-
|
|
8318
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
8319
|
-
if (returnOutput === true) {
|
|
8320
|
-
return state.output;
|
|
8321
|
-
}
|
|
8322
|
-
|
|
8323
|
-
const opts = options || {};
|
|
8324
|
-
const prepend = opts.contains ? '' : '^';
|
|
8325
|
-
const append = opts.contains ? '' : '$';
|
|
8326
|
-
|
|
8327
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
8328
|
-
if (state && state.negated === true) {
|
|
8329
|
-
source = `^(?!${source}).*$`;
|
|
8330
|
-
}
|
|
8331
|
-
|
|
8332
|
-
const regex = picomatch.toRegex(source, options);
|
|
8333
|
-
if (returnState === true) {
|
|
8334
|
-
regex.state = state;
|
|
8335
|
-
}
|
|
8336
|
-
|
|
8337
|
-
return regex;
|
|
8338
|
-
};
|
|
8339
|
-
|
|
8340
|
-
/**
|
|
8341
|
-
* Create a regular expression from a parsed glob pattern.
|
|
8342
|
-
*
|
|
8343
|
-
* ```js
|
|
8344
|
-
* const picomatch = require('picomatch');
|
|
8345
|
-
* const state = picomatch.parse('*.js');
|
|
8346
|
-
* // picomatch.compileRe(state[, options]);
|
|
8347
|
-
*
|
|
8348
|
-
* console.log(picomatch.compileRe(state));
|
|
8349
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
8350
|
-
* ```
|
|
8351
|
-
* @param {String} `state` The object returned from the `.parse` method.
|
|
8352
|
-
* @param {Object} `options`
|
|
8353
|
-
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
8354
|
-
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
8355
|
-
* @return {RegExp} Returns a regex created from the given pattern.
|
|
8356
|
-
* @api public
|
|
8357
|
-
*/
|
|
8358
|
-
|
|
8359
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
8360
|
-
if (!input || typeof input !== 'string') {
|
|
8361
|
-
throw new TypeError('Expected a non-empty string');
|
|
8362
|
-
}
|
|
8363
|
-
|
|
8364
|
-
let parsed = { negated: false, fastpaths: true };
|
|
8365
|
-
|
|
8366
|
-
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
8367
|
-
parsed.output = parse.fastpaths(input, options);
|
|
8368
|
-
}
|
|
8369
|
-
|
|
8370
|
-
if (!parsed.output) {
|
|
8371
|
-
parsed = parse(input, options);
|
|
8372
|
-
}
|
|
8373
|
-
|
|
8374
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
8375
|
-
};
|
|
8376
|
-
|
|
8377
|
-
/**
|
|
8378
|
-
* Create a regular expression from the given regex source string.
|
|
8379
|
-
*
|
|
8380
|
-
* ```js
|
|
8381
|
-
* const picomatch = require('picomatch');
|
|
8382
|
-
* // picomatch.toRegex(source[, options]);
|
|
8383
|
-
*
|
|
8384
|
-
* const { output } = picomatch.parse('*.js');
|
|
8385
|
-
* console.log(picomatch.toRegex(output));
|
|
8386
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
8387
|
-
* ```
|
|
8388
|
-
* @param {String} `source` Regular expression source string.
|
|
8389
|
-
* @param {Object} `options`
|
|
8390
|
-
* @return {RegExp}
|
|
8391
|
-
* @api public
|
|
8392
|
-
*/
|
|
8393
|
-
|
|
8394
|
-
picomatch.toRegex = (source, options) => {
|
|
8395
|
-
try {
|
|
8396
|
-
const opts = options || {};
|
|
8397
|
-
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
8398
|
-
} catch (err) {
|
|
8399
|
-
if (options && options.debug === true) throw err;
|
|
8400
|
-
return /$^/;
|
|
8401
|
-
}
|
|
8402
|
-
};
|
|
8403
|
-
|
|
8404
|
-
/**
|
|
8405
|
-
* Picomatch constants.
|
|
8406
|
-
* @return {Object}
|
|
8407
|
-
*/
|
|
8408
|
-
|
|
8409
|
-
picomatch.constants = constants;
|
|
8410
|
-
|
|
8411
|
-
/**
|
|
8412
|
-
* Expose "picomatch"
|
|
8413
|
-
*/
|
|
8414
|
-
|
|
8415
|
-
picomatch_1$1 = picomatch;
|
|
8416
|
-
return picomatch_1$1;
|
|
8417
|
-
}
|
|
8418
|
-
|
|
8419
|
-
var picomatch_1;
|
|
8420
|
-
var hasRequiredPicomatch;
|
|
8421
|
-
|
|
8422
|
-
function requirePicomatch () {
|
|
8423
|
-
if (hasRequiredPicomatch) return picomatch_1;
|
|
8424
|
-
hasRequiredPicomatch = 1;
|
|
8425
|
-
|
|
8426
|
-
const pico = requirePicomatch$1();
|
|
8427
|
-
const utils = requireUtils();
|
|
8428
|
-
|
|
8429
|
-
function picomatch(glob, options, returnState = false) {
|
|
8430
|
-
// default to os.platform()
|
|
8431
|
-
if (options && (options.windows === null || options.windows === undefined)) {
|
|
8432
|
-
// don't mutate the original options object
|
|
8433
|
-
options = { ...options, windows: utils.isWindows() };
|
|
8434
|
-
}
|
|
8435
|
-
|
|
8436
|
-
return pico(glob, options, returnState);
|
|
8437
|
-
}
|
|
8438
|
-
|
|
8439
|
-
Object.assign(picomatch, pico);
|
|
8440
|
-
picomatch_1 = picomatch;
|
|
8441
|
-
return picomatch_1;
|
|
8442
|
-
}
|
|
8443
|
-
|
|
8444
|
-
var hasRequiredBuilder;
|
|
8445
|
-
|
|
8446
|
-
function requireBuilder () {
|
|
8447
|
-
if (hasRequiredBuilder) return builder;
|
|
8448
|
-
hasRequiredBuilder = 1;
|
|
8449
|
-
Object.defineProperty(builder, "__esModule", { value: true });
|
|
8450
|
-
builder.Builder = void 0;
|
|
8451
|
-
const path_1 = require$$0$4;
|
|
8452
|
-
const api_builder_1 = requireApiBuilder();
|
|
8453
|
-
var pm = null;
|
|
8454
|
-
/* c8 ignore next 6 */
|
|
8455
|
-
try {
|
|
8456
|
-
require.resolve("picomatch");
|
|
8457
|
-
pm = requirePicomatch();
|
|
8458
|
-
}
|
|
8459
|
-
catch (_e) {
|
|
8460
|
-
// do nothing
|
|
8461
|
-
}
|
|
8462
|
-
class Builder {
|
|
8463
|
-
globCache = {};
|
|
8464
|
-
options = {
|
|
8465
|
-
maxDepth: Infinity,
|
|
8466
|
-
suppressErrors: true,
|
|
8467
|
-
pathSeparator: path_1.sep,
|
|
8468
|
-
filters: [],
|
|
8469
|
-
};
|
|
8470
|
-
globFunction;
|
|
8471
|
-
constructor(options) {
|
|
8472
|
-
this.options = { ...this.options, ...options };
|
|
8473
|
-
this.globFunction = this.options.globFunction;
|
|
8474
|
-
}
|
|
8475
|
-
group() {
|
|
8476
|
-
this.options.group = true;
|
|
8477
|
-
return this;
|
|
8478
|
-
}
|
|
8479
|
-
withPathSeparator(separator) {
|
|
8480
|
-
this.options.pathSeparator = separator;
|
|
8481
|
-
return this;
|
|
8482
|
-
}
|
|
8483
|
-
withBasePath() {
|
|
8484
|
-
this.options.includeBasePath = true;
|
|
8485
|
-
return this;
|
|
8486
|
-
}
|
|
8487
|
-
withRelativePaths() {
|
|
8488
|
-
this.options.relativePaths = true;
|
|
8489
|
-
return this;
|
|
8490
|
-
}
|
|
8491
|
-
withDirs() {
|
|
8492
|
-
this.options.includeDirs = true;
|
|
8493
|
-
return this;
|
|
8494
|
-
}
|
|
8495
|
-
withMaxDepth(depth) {
|
|
8496
|
-
this.options.maxDepth = depth;
|
|
8497
|
-
return this;
|
|
8498
|
-
}
|
|
8499
|
-
withMaxFiles(limit) {
|
|
8500
|
-
this.options.maxFiles = limit;
|
|
8501
|
-
return this;
|
|
8502
|
-
}
|
|
8503
|
-
withFullPaths() {
|
|
8504
|
-
this.options.resolvePaths = true;
|
|
8505
|
-
this.options.includeBasePath = true;
|
|
8506
|
-
return this;
|
|
8507
|
-
}
|
|
8508
|
-
withErrors() {
|
|
8509
|
-
this.options.suppressErrors = false;
|
|
8510
|
-
return this;
|
|
8511
|
-
}
|
|
8512
|
-
withSymlinks({ resolvePaths = true } = {}) {
|
|
8513
|
-
this.options.resolveSymlinks = true;
|
|
8514
|
-
this.options.useRealPaths = resolvePaths;
|
|
8515
|
-
return this.withFullPaths();
|
|
8516
|
-
}
|
|
8517
|
-
withAbortSignal(signal) {
|
|
8518
|
-
this.options.signal = signal;
|
|
8519
|
-
return this;
|
|
8520
|
-
}
|
|
8521
|
-
normalize() {
|
|
8522
|
-
this.options.normalizePath = true;
|
|
8523
|
-
return this;
|
|
8524
|
-
}
|
|
8525
|
-
filter(predicate) {
|
|
8526
|
-
this.options.filters.push(predicate);
|
|
8527
|
-
return this;
|
|
8528
|
-
}
|
|
8529
|
-
onlyDirs() {
|
|
8530
|
-
this.options.excludeFiles = true;
|
|
8531
|
-
this.options.includeDirs = true;
|
|
8532
|
-
return this;
|
|
8533
|
-
}
|
|
8534
|
-
exclude(predicate) {
|
|
8535
|
-
this.options.exclude = predicate;
|
|
8536
|
-
return this;
|
|
8537
|
-
}
|
|
8538
|
-
onlyCounts() {
|
|
8539
|
-
this.options.onlyCounts = true;
|
|
8540
|
-
return this;
|
|
8541
|
-
}
|
|
8542
|
-
crawl(root) {
|
|
8543
|
-
return new api_builder_1.APIBuilder(root || ".", this.options);
|
|
8544
|
-
}
|
|
8545
|
-
withGlobFunction(fn) {
|
|
8546
|
-
// cast this since we don't have the new type params yet
|
|
8547
|
-
this.globFunction = fn;
|
|
8548
|
-
return this;
|
|
8549
|
-
}
|
|
8550
|
-
/**
|
|
8551
|
-
* @deprecated Pass options using the constructor instead:
|
|
8552
|
-
* ```ts
|
|
8553
|
-
* new fdir(options).crawl("/path/to/root");
|
|
8554
|
-
* ```
|
|
8555
|
-
* This method will be removed in v7.0
|
|
8556
|
-
*/
|
|
8557
|
-
/* c8 ignore next 4 */
|
|
8558
|
-
crawlWithOptions(root, options) {
|
|
8559
|
-
this.options = { ...this.options, ...options };
|
|
8560
|
-
return new api_builder_1.APIBuilder(root || ".", this.options);
|
|
8561
|
-
}
|
|
8562
|
-
glob(...patterns) {
|
|
8563
|
-
if (this.globFunction) {
|
|
8564
|
-
return this.globWithOptions(patterns);
|
|
8565
|
-
}
|
|
8566
|
-
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
8567
|
-
}
|
|
8568
|
-
globWithOptions(patterns, ...options) {
|
|
8569
|
-
const globFn = (this.globFunction || pm);
|
|
8570
|
-
/* c8 ignore next 5 */
|
|
8571
|
-
if (!globFn) {
|
|
8572
|
-
throw new Error('Please specify a glob function to use glob matching.');
|
|
8573
|
-
}
|
|
8574
|
-
var isMatch = this.globCache[patterns.join("\0")];
|
|
8575
|
-
if (!isMatch) {
|
|
8576
|
-
isMatch = globFn(patterns, ...options);
|
|
8577
|
-
this.globCache[patterns.join("\0")] = isMatch;
|
|
8578
|
-
}
|
|
8579
|
-
this.options.filters.push((path) => isMatch(path));
|
|
8580
|
-
return this;
|
|
8581
|
-
}
|
|
8582
|
-
}
|
|
8583
|
-
builder.Builder = Builder;
|
|
8584
|
-
return builder;
|
|
8585
|
-
}
|
|
8586
|
-
|
|
8587
|
-
var types = {};
|
|
8588
|
-
|
|
8589
|
-
var hasRequiredTypes;
|
|
8590
|
-
|
|
8591
|
-
function requireTypes () {
|
|
8592
|
-
if (hasRequiredTypes) return types;
|
|
8593
|
-
hasRequiredTypes = 1;
|
|
8594
|
-
Object.defineProperty(types, "__esModule", { value: true });
|
|
8595
|
-
return types;
|
|
8596
|
-
}
|
|
8597
|
-
|
|
8598
|
-
var hasRequiredDist;
|
|
8599
|
-
|
|
8600
|
-
function requireDist () {
|
|
8601
|
-
if (hasRequiredDist) return dist;
|
|
8602
|
-
hasRequiredDist = 1;
|
|
8603
|
-
(function (exports) {
|
|
8604
|
-
var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8605
|
-
if (k2 === undefined) k2 = k;
|
|
8606
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8607
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8608
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8609
|
-
}
|
|
8610
|
-
Object.defineProperty(o, k2, desc);
|
|
8611
|
-
}) : (function(o, m, k, k2) {
|
|
8612
|
-
if (k2 === undefined) k2 = k;
|
|
8613
|
-
o[k2] = m[k];
|
|
8614
|
-
}));
|
|
8615
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
8616
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
8617
|
-
};
|
|
8618
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8619
|
-
exports.fdir = void 0;
|
|
8620
|
-
const builder_1 = requireBuilder();
|
|
8621
|
-
Object.defineProperty(exports, "fdir", { enumerable: true, get: function () { return builder_1.Builder; } });
|
|
8622
|
-
__exportStar(requireTypes(), exports);
|
|
8623
|
-
} (dist));
|
|
8624
|
-
return dist;
|
|
8625
|
-
}
|
|
8626
|
-
|
|
8627
|
-
var distExports = requireDist();
|
|
8628
|
-
|
|
8629
|
-
var picomatchExports = requirePicomatch();
|
|
8630
|
-
var picomatch2 = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
|
|
8631
|
-
|
|
8632
|
-
// src/index.ts
|
|
8633
|
-
var ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
8634
|
-
function getPartialMatcher(patterns, options) {
|
|
8635
|
-
const patternsCount = patterns.length;
|
|
8636
|
-
const patternsParts = Array(patternsCount);
|
|
8637
|
-
const regexes = Array(patternsCount);
|
|
8638
|
-
for (let i = 0; i < patternsCount; i++) {
|
|
8639
|
-
const parts = splitPattern(patterns[i]);
|
|
8640
|
-
patternsParts[i] = parts;
|
|
8641
|
-
const partsCount = parts.length;
|
|
8642
|
-
const partRegexes = Array(partsCount);
|
|
8643
|
-
for (let j = 0; j < partsCount; j++) {
|
|
8644
|
-
partRegexes[j] = picomatch2.makeRe(parts[j], options);
|
|
8645
|
-
}
|
|
8646
|
-
regexes[i] = partRegexes;
|
|
8647
|
-
}
|
|
8648
|
-
return (input) => {
|
|
8649
|
-
const inputParts = input.split("/");
|
|
8650
|
-
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) {
|
|
8651
|
-
return true;
|
|
8652
|
-
}
|
|
8653
|
-
for (let i = 0; i < patterns.length; i++) {
|
|
8654
|
-
const patternParts = patternsParts[i];
|
|
8655
|
-
const regex = regexes[i];
|
|
8656
|
-
const inputPatternCount = inputParts.length;
|
|
8657
|
-
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
8658
|
-
let j = 0;
|
|
8659
|
-
while (j < minParts) {
|
|
8660
|
-
const part = patternParts[j];
|
|
8661
|
-
if (part.includes("/")) {
|
|
8662
|
-
return true;
|
|
8663
|
-
}
|
|
8664
|
-
const match = regex[j].test(inputParts[j]);
|
|
8665
|
-
if (!match) {
|
|
8666
|
-
break;
|
|
8667
|
-
}
|
|
8668
|
-
if (part === "**") {
|
|
8669
|
-
return true;
|
|
8670
|
-
}
|
|
8671
|
-
j++;
|
|
8672
|
-
}
|
|
8673
|
-
if (j === inputPatternCount) {
|
|
8674
|
-
return true;
|
|
8675
|
-
}
|
|
8676
|
-
}
|
|
8677
|
-
return false;
|
|
8678
|
-
};
|
|
8679
|
-
}
|
|
8680
|
-
var splitPatternOptions = { parts: true };
|
|
8681
|
-
function splitPattern(path2) {
|
|
8682
|
-
var _a;
|
|
8683
|
-
const result = picomatch2.scan(path2, splitPatternOptions);
|
|
8684
|
-
return ((_a = result.parts) == null ? void 0 : _a.length) ? result.parts : [path2];
|
|
8685
|
-
}
|
|
8686
|
-
var isWin = process.platform === "win32";
|
|
8687
|
-
var POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
8688
|
-
var WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
8689
|
-
var escapePosixPath = (path2) => path2.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
8690
|
-
var escapeWin32Path = (path2) => path2.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
8691
|
-
var escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
8692
|
-
function isDynamicPattern(pattern, options) {
|
|
8693
|
-
const scan = picomatch2.scan(pattern);
|
|
8694
|
-
return scan.isGlob || scan.negated;
|
|
8695
|
-
}
|
|
8696
|
-
function log(...tasks) {
|
|
8697
|
-
console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
|
|
8698
|
-
}
|
|
8699
|
-
|
|
8700
|
-
// src/index.ts
|
|
8701
|
-
var PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
8702
|
-
var ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
8703
|
-
var BACKSLASHES = /\\/g;
|
|
8704
|
-
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
8705
|
-
var _a;
|
|
8706
|
-
let result = pattern;
|
|
8707
|
-
if (pattern.endsWith("/")) {
|
|
8708
|
-
result = pattern.slice(0, -1);
|
|
8709
|
-
}
|
|
8710
|
-
if (!result.endsWith("*") && expandDirectories) {
|
|
8711
|
-
result += "/**";
|
|
8712
|
-
}
|
|
8713
|
-
if (require$$0$4.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) {
|
|
8714
|
-
result = posix.relative(escapePath(cwd), result);
|
|
8715
|
-
} else {
|
|
8716
|
-
result = posix.normalize(result);
|
|
8717
|
-
}
|
|
8718
|
-
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
8719
|
-
if (parentDirectoryMatch == null ? void 0 : parentDirectoryMatch[0]) {
|
|
8720
|
-
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0]);
|
|
8721
|
-
if (props.root.length > potentialRoot.length) {
|
|
8722
|
-
props.root = potentialRoot;
|
|
8723
|
-
props.depthOffset = -(parentDirectoryMatch[0].length + 1) / 3;
|
|
8724
|
-
}
|
|
8725
|
-
} else if (!isIgnore && props.depthOffset >= 0) {
|
|
8726
|
-
const parts = splitPattern(result);
|
|
8727
|
-
(_a = props.commonPath) != null ? _a : props.commonPath = parts;
|
|
8728
|
-
const newCommonPath = [];
|
|
8729
|
-
const length = Math.min(props.commonPath.length, parts.length);
|
|
8730
|
-
for (let i = 0; i < length; i++) {
|
|
8731
|
-
const part = parts[i];
|
|
8732
|
-
if (part === "**" && !parts[i + 1]) {
|
|
8733
|
-
newCommonPath.pop();
|
|
8734
|
-
break;
|
|
8735
|
-
}
|
|
8736
|
-
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) {
|
|
8737
|
-
break;
|
|
8738
|
-
}
|
|
8739
|
-
newCommonPath.push(part);
|
|
8740
|
-
}
|
|
8741
|
-
props.depthOffset = newCommonPath.length;
|
|
8742
|
-
props.commonPath = newCommonPath;
|
|
8743
|
-
props.root = newCommonPath.length > 0 ? `${cwd}/${newCommonPath.join("/")}` : cwd;
|
|
8744
|
-
}
|
|
8745
|
-
return result;
|
|
8746
|
-
}
|
|
8747
|
-
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
|
8748
|
-
if (typeof patterns === "string") {
|
|
8749
|
-
patterns = [patterns];
|
|
8750
|
-
} else if (!patterns) {
|
|
8751
|
-
patterns = ["**/*"];
|
|
8752
|
-
}
|
|
8753
|
-
if (typeof ignore === "string") {
|
|
8754
|
-
ignore = [ignore];
|
|
8755
|
-
}
|
|
8756
|
-
const matchPatterns = [];
|
|
8757
|
-
const ignorePatterns = [];
|
|
8758
|
-
for (const pattern of ignore) {
|
|
8759
|
-
if (!pattern) {
|
|
8760
|
-
continue;
|
|
8761
|
-
}
|
|
8762
|
-
if (pattern[0] !== "!" || pattern[1] === "(") {
|
|
8763
|
-
ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
|
8764
|
-
}
|
|
8765
|
-
}
|
|
8766
|
-
for (const pattern of patterns) {
|
|
8767
|
-
if (!pattern) {
|
|
8768
|
-
continue;
|
|
8769
|
-
}
|
|
8770
|
-
if (pattern[0] !== "!" || pattern[1] === "(") {
|
|
8771
|
-
matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
|
8772
|
-
} else if (pattern[1] !== "!" || pattern[2] === "(") {
|
|
8773
|
-
ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
|
8774
|
-
}
|
|
8775
|
-
}
|
|
8776
|
-
return { match: matchPatterns, ignore: ignorePatterns };
|
|
8777
|
-
}
|
|
8778
|
-
function getRelativePath(path2, cwd, root) {
|
|
8779
|
-
return posix.relative(cwd, `${root}/${path2}`) || ".";
|
|
8780
|
-
}
|
|
8781
|
-
function processPath(path2, cwd, root, isDirectory, absolute) {
|
|
8782
|
-
const relativePath = absolute ? path2.slice(root.length + 1) || "." : path2;
|
|
8783
|
-
if (root === cwd) {
|
|
8784
|
-
return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
|
8785
|
-
}
|
|
8786
|
-
return getRelativePath(relativePath, cwd, root);
|
|
8787
|
-
}
|
|
8788
|
-
function formatPaths(paths, cwd, root) {
|
|
8789
|
-
for (let i = paths.length - 1; i >= 0; i--) {
|
|
8790
|
-
const path2 = paths[i];
|
|
8791
|
-
paths[i] = getRelativePath(path2, cwd, root) + (!path2 || path2.endsWith("/") ? "/" : "");
|
|
8792
|
-
}
|
|
8793
|
-
return paths;
|
|
8794
|
-
}
|
|
8795
|
-
function crawl(options, cwd, sync) {
|
|
8796
|
-
if (process.env.TINYGLOBBY_DEBUG) {
|
|
8797
|
-
options.debug = true;
|
|
8798
|
-
}
|
|
8799
|
-
if (options.debug) {
|
|
8800
|
-
log("globbing with options:", options, "cwd:", cwd);
|
|
8801
|
-
}
|
|
8802
|
-
if (Array.isArray(options.patterns) && options.patterns.length === 0) {
|
|
8803
|
-
return sync ? [] : Promise.resolve([]);
|
|
8804
|
-
}
|
|
8805
|
-
const props = {
|
|
8806
|
-
root: cwd,
|
|
8807
|
-
commonPath: null,
|
|
8808
|
-
depthOffset: 0
|
|
8809
|
-
};
|
|
8810
|
-
const processed = processPatterns(options, cwd, props);
|
|
8811
|
-
const nocase = options.caseSensitiveMatch === false;
|
|
8812
|
-
if (options.debug) {
|
|
8813
|
-
log("internal processing patterns:", processed);
|
|
8814
|
-
}
|
|
8815
|
-
const matcher = picomatch2(processed.match, {
|
|
8816
|
-
dot: options.dot,
|
|
8817
|
-
nocase,
|
|
8818
|
-
ignore: processed.ignore
|
|
8819
|
-
});
|
|
8820
|
-
const ignore = picomatch2(processed.ignore, {
|
|
8821
|
-
dot: options.dot,
|
|
8822
|
-
nocase
|
|
8823
|
-
});
|
|
8824
|
-
const partialMatcher = getPartialMatcher(processed.match, {
|
|
8825
|
-
dot: options.dot,
|
|
8826
|
-
nocase
|
|
8827
|
-
});
|
|
8828
|
-
const fdirOptions = {
|
|
8829
|
-
// use relative paths in the matcher
|
|
8830
|
-
filters: [
|
|
8831
|
-
options.debug ? (p, isDirectory) => {
|
|
8832
|
-
const path2 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
|
8833
|
-
const matches = matcher(path2);
|
|
8834
|
-
if (matches) {
|
|
8835
|
-
log(`matched ${path2}`);
|
|
8836
|
-
}
|
|
8837
|
-
return matches;
|
|
8838
|
-
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))
|
|
8839
|
-
],
|
|
8840
|
-
exclude: options.debug ? (_, p) => {
|
|
8841
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
8842
|
-
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
8843
|
-
if (skipped) {
|
|
8844
|
-
log(`skipped ${p}`);
|
|
8845
|
-
} else {
|
|
8846
|
-
log(`crawling ${p}`);
|
|
8847
|
-
}
|
|
8848
|
-
return skipped;
|
|
8849
|
-
} : (_, p) => {
|
|
8850
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
8851
|
-
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
8852
|
-
},
|
|
8853
|
-
pathSeparator: "/",
|
|
8854
|
-
relativePaths: true,
|
|
8855
|
-
resolveSymlinks: true
|
|
8856
|
-
};
|
|
8857
|
-
if (options.deep) {
|
|
8858
|
-
fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
|
8859
|
-
}
|
|
8860
|
-
if (options.absolute) {
|
|
8861
|
-
fdirOptions.relativePaths = false;
|
|
8862
|
-
fdirOptions.resolvePaths = true;
|
|
8863
|
-
fdirOptions.includeBasePath = true;
|
|
8864
|
-
}
|
|
8865
|
-
if (options.followSymbolicLinks === false) {
|
|
8866
|
-
fdirOptions.resolveSymlinks = false;
|
|
8867
|
-
fdirOptions.excludeSymlinks = true;
|
|
8868
|
-
}
|
|
8869
|
-
if (options.onlyDirectories) {
|
|
8870
|
-
fdirOptions.excludeFiles = true;
|
|
8871
|
-
fdirOptions.includeDirs = true;
|
|
8872
|
-
} else if (options.onlyFiles === false) {
|
|
8873
|
-
fdirOptions.includeDirs = true;
|
|
8874
|
-
}
|
|
8875
|
-
props.root = props.root.replace(BACKSLASHES, "");
|
|
8876
|
-
const root = props.root;
|
|
8877
|
-
if (options.debug) {
|
|
8878
|
-
log("internal properties:", props);
|
|
8879
|
-
}
|
|
8880
|
-
const api = new distExports.fdir(fdirOptions).crawl(root);
|
|
8881
|
-
if (cwd === root || options.absolute) {
|
|
8882
|
-
return sync ? api.sync() : api.withPromise();
|
|
8883
|
-
}
|
|
8884
|
-
return sync ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
|
8885
|
-
}
|
|
8886
|
-
async function glob(patternsOrOptions, options) {
|
|
8887
|
-
if (patternsOrOptions && (options == null ? void 0 : options.patterns)) {
|
|
8888
|
-
throw new Error("Cannot pass patterns as both an argument and an option");
|
|
8889
|
-
}
|
|
8890
|
-
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? { ...options, patterns: patternsOrOptions } : patternsOrOptions;
|
|
8891
|
-
const cwd = opts.cwd ? require$$0$4.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
8892
|
-
return crawl(opts, cwd, false);
|
|
8893
|
-
}
|
|
8894
|
-
|
|
8895
|
-
function serializeConfig(config, coreConfig, viteConfig) {
|
|
8896
|
-
const optimizer = config.deps?.optimizer;
|
|
8897
|
-
const poolOptions = config.poolOptions;
|
|
8898
|
-
const isolate = viteConfig?.test?.isolate;
|
|
8899
|
-
return {
|
|
8900
|
-
environmentOptions: config.environmentOptions,
|
|
8901
|
-
mode: config.mode,
|
|
8902
|
-
isolate: config.isolate,
|
|
8903
|
-
base: config.base,
|
|
8904
|
-
logHeapUsage: config.logHeapUsage,
|
|
8905
|
-
runner: config.runner,
|
|
8906
|
-
bail: config.bail,
|
|
8907
|
-
defines: config.defines,
|
|
8908
|
-
chaiConfig: config.chaiConfig,
|
|
8909
|
-
setupFiles: config.setupFiles,
|
|
8910
|
-
allowOnly: config.allowOnly,
|
|
8911
|
-
testTimeout: config.testTimeout,
|
|
8912
|
-
testNamePattern: config.testNamePattern,
|
|
8913
|
-
hookTimeout: config.hookTimeout,
|
|
8914
|
-
clearMocks: config.clearMocks,
|
|
8915
|
-
mockReset: config.mockReset,
|
|
8916
|
-
restoreMocks: config.restoreMocks,
|
|
8917
|
-
unstubEnvs: config.unstubEnvs,
|
|
8918
|
-
unstubGlobals: config.unstubGlobals,
|
|
8919
|
-
maxConcurrency: config.maxConcurrency,
|
|
8920
|
-
pool: config.pool,
|
|
8921
|
-
expect: config.expect,
|
|
8922
|
-
snapshotSerializers: config.snapshotSerializers,
|
|
8923
|
-
diff: config.diff,
|
|
8924
|
-
retry: config.retry,
|
|
8925
|
-
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
8926
|
-
root: config.root,
|
|
8927
|
-
name: config.name,
|
|
8928
|
-
globals: config.globals,
|
|
8929
|
-
snapshotEnvironment: config.snapshotEnvironment,
|
|
8930
|
-
passWithNoTests: config.passWithNoTests,
|
|
8931
|
-
coverage: ((coverage) => {
|
|
8932
|
-
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
8933
|
-
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
8934
|
-
return {
|
|
8935
|
-
reportsDirectory: coverage.reportsDirectory,
|
|
8936
|
-
provider: coverage.provider,
|
|
8937
|
-
enabled: coverage.enabled,
|
|
8938
|
-
htmlReporter: htmlReporter ? { subdir } : undefined,
|
|
8939
|
-
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : undefined
|
|
8940
|
-
};
|
|
8941
|
-
})(config.coverage),
|
|
8942
|
-
fakeTimers: config.fakeTimers,
|
|
8943
|
-
poolOptions: {
|
|
8944
|
-
forks: {
|
|
8945
|
-
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
8946
|
-
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
8947
|
-
},
|
|
8948
|
-
threads: {
|
|
8949
|
-
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
8950
|
-
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
8951
|
-
},
|
|
8952
|
-
vmThreads: { singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false },
|
|
8953
|
-
vmForks: { singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false }
|
|
8954
|
-
},
|
|
8955
|
-
deps: {
|
|
8956
|
-
web: config.deps.web || {},
|
|
8957
|
-
optimizer: {
|
|
8958
|
-
web: { enabled: optimizer?.web?.enabled ?? true },
|
|
8959
|
-
ssr: { enabled: optimizer?.ssr?.enabled ?? true }
|
|
8960
|
-
},
|
|
8961
|
-
interopDefault: config.deps.interopDefault,
|
|
8962
|
-
moduleDirectories: config.deps.moduleDirectories
|
|
8963
|
-
},
|
|
8964
|
-
snapshotOptions: {
|
|
8965
|
-
snapshotEnvironment: undefined,
|
|
8966
|
-
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
8967
|
-
snapshotFormat: {
|
|
8968
|
-
...coreConfig.snapshotOptions.snapshotFormat,
|
|
8969
|
-
compareKeys: undefined
|
|
8970
|
-
},
|
|
8971
|
-
expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
|
|
8972
|
-
},
|
|
8973
|
-
sequence: {
|
|
8974
|
-
shuffle: coreConfig.sequence.shuffle,
|
|
8975
|
-
concurrent: coreConfig.sequence.concurrent,
|
|
8976
|
-
seed: coreConfig.sequence.seed,
|
|
8977
|
-
hooks: coreConfig.sequence.hooks,
|
|
8978
|
-
setupFiles: coreConfig.sequence.setupFiles
|
|
8979
|
-
},
|
|
8980
|
-
inspect: coreConfig.inspect,
|
|
8981
|
-
inspectBrk: coreConfig.inspectBrk,
|
|
8982
|
-
inspector: coreConfig.inspector,
|
|
8983
|
-
watch: config.watch,
|
|
8984
|
-
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
8985
|
-
env: {
|
|
8986
|
-
...viteConfig?.env,
|
|
8987
|
-
...config.env
|
|
8988
|
-
},
|
|
8989
|
-
browser: ((browser) => {
|
|
8990
|
-
return {
|
|
8991
|
-
name: browser.name,
|
|
8992
|
-
headless: browser.headless,
|
|
8993
|
-
isolate: browser.isolate,
|
|
8994
|
-
fileParallelism: browser.fileParallelism,
|
|
8995
|
-
ui: browser.ui,
|
|
8996
|
-
viewport: browser.viewport,
|
|
8997
|
-
screenshotFailures: browser.screenshotFailures,
|
|
8998
|
-
locators: { testIdAttribute: browser.locators.testIdAttribute },
|
|
8999
|
-
providerOptions: browser.provider === "playwright" ? { actionTimeout: browser.providerOptions?.context?.actionTimeout } : {}
|
|
9000
|
-
};
|
|
9001
|
-
})(config.browser),
|
|
9002
|
-
standalone: config.standalone,
|
|
9003
|
-
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace,
|
|
9004
|
-
benchmark: config.benchmark && { includeSamples: config.benchmark.includeSamples }
|
|
9005
|
-
};
|
|
9006
|
-
}
|
|
9007
|
-
|
|
9008
|
-
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
9009
|
-
const globalSetupFiles = toArray(globalSetup);
|
|
9010
|
-
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
|
|
9011
|
-
}
|
|
9012
|
-
async function loadGlobalSetupFile(file, runner) {
|
|
9013
|
-
const m = await runner.executeFile(file);
|
|
9014
|
-
for (const exp of [
|
|
9015
|
-
"default",
|
|
9016
|
-
"setup",
|
|
9017
|
-
"teardown"
|
|
9018
|
-
]) {
|
|
9019
|
-
if (m[exp] != null && typeof m[exp] !== "function") {
|
|
9020
|
-
throw new Error(`invalid export in globalSetup file ${file}: ${exp} must be a function`);
|
|
9021
|
-
}
|
|
9022
|
-
}
|
|
9023
|
-
if (m.default) {
|
|
9024
|
-
return {
|
|
9025
|
-
file,
|
|
9026
|
-
setup: m.default
|
|
9027
|
-
};
|
|
9028
|
-
} else if (m.setup || m.teardown) {
|
|
9029
|
-
return {
|
|
9030
|
-
file,
|
|
9031
|
-
setup: m.setup,
|
|
9032
|
-
teardown: m.teardown
|
|
9033
|
-
};
|
|
9034
|
-
} else {
|
|
9035
|
-
throw new Error(`invalid globalSetup file ${file}. Must export setup, teardown or have a default export`);
|
|
9036
|
-
}
|
|
9037
|
-
}
|
|
9038
|
-
|
|
9039
|
-
function CoverageTransform(ctx) {
|
|
9040
|
-
return {
|
|
9041
|
-
name: "vitest:coverage-transform",
|
|
9042
|
-
transform(srcCode, id) {
|
|
9043
|
-
return ctx.coverageProvider?.onFileTransform?.(srcCode, normalizeRequestId(id), this);
|
|
9044
|
-
}
|
|
9045
|
-
};
|
|
9046
|
-
}
|
|
9047
|
-
|
|
9048
|
-
function MocksPlugins(options = {}) {
|
|
9049
|
-
const normalizedDistDir = normalize(distDir);
|
|
9050
|
-
return [hoistMocksPlugin({
|
|
9051
|
-
filter(id) {
|
|
9052
|
-
if (id.includes(normalizedDistDir)) {
|
|
9053
|
-
return false;
|
|
9054
|
-
}
|
|
9055
|
-
if (options.filter) {
|
|
9056
|
-
return options.filter(id);
|
|
9057
|
-
}
|
|
9058
|
-
return true;
|
|
9059
|
-
},
|
|
9060
|
-
codeFrameGenerator(node, id, code) {
|
|
9061
|
-
return generateCodeFrame(code, 4, node.start + 1);
|
|
9062
|
-
}
|
|
9063
|
-
}), automockPlugin()];
|
|
9064
|
-
}
|
|
9065
|
-
|
|
9066
|
-
function generateCssFilenameHash(filepath) {
|
|
9067
|
-
return hash("md5", filepath, "hex").slice(0, 6);
|
|
9068
|
-
}
|
|
9069
|
-
function generateScopedClassName(strategy, name, filename) {
|
|
9070
|
-
if (strategy === "scoped") {
|
|
9071
|
-
return null;
|
|
9072
|
-
}
|
|
9073
|
-
if (strategy === "non-scoped") {
|
|
9074
|
-
return name;
|
|
9075
|
-
}
|
|
9076
|
-
const hash = generateCssFilenameHash(filename);
|
|
9077
|
-
return `_${name}_${hash}`;
|
|
9078
|
-
}
|
|
9079
|
-
|
|
9080
|
-
const LogLevels = {
|
|
9081
|
-
silent: 0,
|
|
9082
|
-
error: 1,
|
|
9083
|
-
warn: 2,
|
|
9084
|
-
info: 3
|
|
9085
|
-
};
|
|
9086
|
-
function clearScreen(logger) {
|
|
9087
|
-
const repeatCount = process.stdout.rows - 2;
|
|
9088
|
-
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
|
9089
|
-
logger.clearScreen(blank);
|
|
5802
|
+
const LogLevels = {
|
|
5803
|
+
silent: 0,
|
|
5804
|
+
error: 1,
|
|
5805
|
+
warn: 2,
|
|
5806
|
+
info: 3
|
|
5807
|
+
};
|
|
5808
|
+
function clearScreen(logger) {
|
|
5809
|
+
const repeatCount = process.stdout.rows - 2;
|
|
5810
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
|
5811
|
+
logger.clearScreen(blank);
|
|
9090
5812
|
}
|
|
9091
5813
|
let lastType;
|
|
9092
5814
|
let lastMsg;
|
|
@@ -9981,26 +6703,6 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
9981
6703
|
name = options.workspacePath.toString();
|
|
9982
6704
|
}
|
|
9983
6705
|
}
|
|
9984
|
-
const workspaceNames = [name];
|
|
9985
|
-
if (viteConfig.test?.browser?.enabled) {
|
|
9986
|
-
if (viteConfig.test.browser.name) {
|
|
9987
|
-
const browser = viteConfig.test.browser.name;
|
|
9988
|
-
workspaceNames.push(name ? `${name} (${browser})` : browser);
|
|
9989
|
-
}
|
|
9990
|
-
viteConfig.test.browser.instances?.forEach((instance) => {
|
|
9991
|
-
instance.name ??= name ? `${name} (${instance.browser})` : instance.browser;
|
|
9992
|
-
workspaceNames.push(instance.name);
|
|
9993
|
-
});
|
|
9994
|
-
}
|
|
9995
|
-
const filters = project.vitest.config.project;
|
|
9996
|
-
if (filters.length) {
|
|
9997
|
-
const hasProject = workspaceNames.some((name) => {
|
|
9998
|
-
return project.vitest.matchesProjectFilter(name);
|
|
9999
|
-
});
|
|
10000
|
-
if (!hasProject) {
|
|
10001
|
-
throw new VitestFilteredOutProjectError();
|
|
10002
|
-
}
|
|
10003
|
-
}
|
|
10004
6706
|
const resolveOptions = getDefaultResolveOptions();
|
|
10005
6707
|
const config = {
|
|
10006
6708
|
root,
|
|
@@ -10026,7 +6728,30 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
10026
6728
|
environments: { ssr: { resolve: resolveOptions } },
|
|
10027
6729
|
test: { name }
|
|
10028
6730
|
};
|
|
6731
|
+
if (project.vitest._options.browser && viteConfig.test?.browser) {
|
|
6732
|
+
viteConfig.test.browser = mergeConfig(viteConfig.test.browser, project.vitest._options.browser);
|
|
6733
|
+
}
|
|
10029
6734
|
config.test.defines = defines;
|
|
6735
|
+
const workspaceNames = [name];
|
|
6736
|
+
if (viteConfig.test?.browser?.enabled) {
|
|
6737
|
+
if (viteConfig.test.browser.name && !viteConfig.test.browser.instances?.length) {
|
|
6738
|
+
const browser = viteConfig.test.browser.name;
|
|
6739
|
+
workspaceNames.push(name ? `${name} (${browser})` : browser);
|
|
6740
|
+
}
|
|
6741
|
+
viteConfig.test.browser.instances?.forEach((instance) => {
|
|
6742
|
+
instance.name ??= name ? `${name} (${instance.browser})` : instance.browser;
|
|
6743
|
+
workspaceNames.push(instance.name);
|
|
6744
|
+
});
|
|
6745
|
+
}
|
|
6746
|
+
const filters = project.vitest.config.project;
|
|
6747
|
+
if (filters.length) {
|
|
6748
|
+
const hasProject = workspaceNames.some((name) => {
|
|
6749
|
+
return project.vitest.matchesProjectFilter(name);
|
|
6750
|
+
});
|
|
6751
|
+
if (!hasProject) {
|
|
6752
|
+
throw new VitestFilteredOutProjectError();
|
|
6753
|
+
}
|
|
6754
|
+
}
|
|
10030
6755
|
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
10031
6756
|
if (classNameStrategy !== "scoped") {
|
|
10032
6757
|
config.css ??= {};
|
|
@@ -10473,8 +7198,14 @@ class TestProject {
|
|
|
10473
7198
|
}
|
|
10474
7199
|
await this.vitest.packageInstaller.ensureInstalled("@vitest/browser", this.config.root, this.vitest.version);
|
|
10475
7200
|
const { createBrowserServer, distRoot } = await import('@vitest/browser');
|
|
10476
|
-
|
|
10477
|
-
|
|
7201
|
+
let cacheDir;
|
|
7202
|
+
const browser = await createBrowserServer(this, this.vite.config.configFile, [{
|
|
7203
|
+
name: "vitest:browser-cacheDir",
|
|
7204
|
+
configResolved(config) {
|
|
7205
|
+
cacheDir = config.cacheDir;
|
|
7206
|
+
}
|
|
7207
|
+
}, ...MocksPlugins({ filter(id) {
|
|
7208
|
+
if (id.includes(distRoot) || id.includes(cacheDir)) {
|
|
10478
7209
|
return false;
|
|
10479
7210
|
}
|
|
10480
7211
|
return true;
|
|
@@ -11267,6 +7998,7 @@ class StateManager {
|
|
|
11267
7998
|
errorsSet = new Set();
|
|
11268
7999
|
processTimeoutCauses = new Set();
|
|
11269
8000
|
reportedTasksMap = new WeakMap();
|
|
8001
|
+
blobs;
|
|
11270
8002
|
catchError(err, type) {
|
|
11271
8003
|
if (isAggregateError(err)) {
|
|
11272
8004
|
return err.errors.forEach((error) => this.catchError(error, type));
|
|
@@ -11778,8 +8510,8 @@ async function resolveBrowserWorkspace(vitest, names, resolvedProjects) {
|
|
|
11778
8510
|
return;
|
|
11779
8511
|
}
|
|
11780
8512
|
const instances = project.config.browser.instances || [];
|
|
11781
|
-
|
|
11782
|
-
|
|
8513
|
+
const browser = project.config.browser.name;
|
|
8514
|
+
if (instances.length === 0 && browser) {
|
|
11783
8515
|
instances.push({
|
|
11784
8516
|
browser,
|
|
11785
8517
|
name: project.name ? `${project.name} (${browser})` : browser
|
|
@@ -11868,7 +8600,7 @@ function cloneConfig(project, { browser,...config }) {
|
|
|
11868
8600
|
testerHtmlPath: testerHtmlPath ?? currentConfig.testerHtmlPath,
|
|
11869
8601
|
screenshotDirectory: screenshotDirectory ?? currentConfig.screenshotDirectory,
|
|
11870
8602
|
screenshotFailures: screenshotFailures ?? currentConfig.screenshotFailures,
|
|
11871
|
-
headless:
|
|
8603
|
+
headless: headless ?? currentConfig.headless,
|
|
11872
8604
|
name: browser,
|
|
11873
8605
|
providerOptions: config,
|
|
11874
8606
|
instances: undefined
|
|
@@ -12183,8 +8915,19 @@ class Vitest {
|
|
|
12183
8915
|
injectTestProjects: this.injectTestProject
|
|
12184
8916
|
}));
|
|
12185
8917
|
}));
|
|
8918
|
+
if (options.browser?.enabled) {
|
|
8919
|
+
const browserProjects = this.projects.filter((p) => p.config.browser.enabled);
|
|
8920
|
+
if (!browserProjects.length) {
|
|
8921
|
+
throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`);
|
|
8922
|
+
}
|
|
8923
|
+
}
|
|
12186
8924
|
if (!this.projects.length) {
|
|
12187
|
-
|
|
8925
|
+
const filter = toArray(resolved.project).join("\", \"");
|
|
8926
|
+
if (filter) {
|
|
8927
|
+
throw new Error(`No projects matched the filter "${filter}".`);
|
|
8928
|
+
} else {
|
|
8929
|
+
throw new Error(`Vitest wasn't able to resolve any project.`);
|
|
8930
|
+
}
|
|
12188
8931
|
}
|
|
12189
8932
|
if (!this.coreWorkspaceProject) {
|
|
12190
8933
|
this.coreWorkspaceProject = TestProject._createBasicProject(this);
|
|
@@ -12320,7 +9063,13 @@ class Vitest {
|
|
|
12320
9063
|
if (this.reporters.some((r) => r instanceof BlobReporter)) {
|
|
12321
9064
|
throw new Error("Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.");
|
|
12322
9065
|
}
|
|
12323
|
-
const { files, errors, coverages } = await readBlobs(this.version, directory || this.config.mergeReports, this.projects);
|
|
9066
|
+
const { files, errors, coverages, executionTimes } = await readBlobs(this.version, directory || this.config.mergeReports, this.projects);
|
|
9067
|
+
this.state.blobs = {
|
|
9068
|
+
files,
|
|
9069
|
+
errors,
|
|
9070
|
+
coverages,
|
|
9071
|
+
executionTimes
|
|
9072
|
+
};
|
|
12324
9073
|
await this.report("onInit", this);
|
|
12325
9074
|
await this.report("onPathsCollected", files.flatMap((f) => f.filepath));
|
|
12326
9075
|
const specifications = [];
|
|
@@ -12519,7 +9268,9 @@ class Vitest {
|
|
|
12519
9268
|
process.exitCode = 1;
|
|
12520
9269
|
}
|
|
12521
9270
|
this.cache.results.updateResults(files);
|
|
12522
|
-
|
|
9271
|
+
try {
|
|
9272
|
+
await this.cache.results.writeToCache();
|
|
9273
|
+
} catch {}
|
|
12523
9274
|
return {
|
|
12524
9275
|
testModules: this.state.getTestModules(),
|
|
12525
9276
|
unhandledErrors: this.state.getUnhandledErrors()
|