vitest 0.0.103 → 0.0.107

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.
@@ -1,346 +0,0 @@
1
- import require$$0 from 'tty';
2
- import { isPackageExists } from 'local-pkg';
3
- import path from 'path';
4
-
5
- var picocolors = {exports: {}};
6
-
7
- let tty = require$$0;
8
-
9
- let isColorSupported =
10
- !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
11
- ("FORCE_COLOR" in process.env ||
12
- process.argv.includes("--color") ||
13
- process.platform === "win32" ||
14
- (tty.isatty(1) && process.env.TERM !== "dumb") ||
15
- "CI" in process.env);
16
-
17
- let formatter =
18
- (open, close, replace = open) =>
19
- input => {
20
- let string = "" + input;
21
- let index = string.indexOf(close, open.length);
22
- return ~index
23
- ? open + replaceClose(string, close, replace, index) + close
24
- : open + string + close
25
- };
26
-
27
- let replaceClose = (string, close, replace, index) => {
28
- let start = string.substring(0, index) + replace;
29
- let end = string.substring(index + close.length);
30
- let nextIndex = end.indexOf(close);
31
- return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
32
- };
33
-
34
- let createColors = (enabled = isColorSupported) => ({
35
- isColorSupported: enabled,
36
- reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
37
- bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
38
- dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
39
- italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
40
- underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
41
- inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
42
- hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
43
- strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
44
- black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
45
- red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
46
- green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
47
- yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
48
- blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
49
- magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
50
- cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
51
- white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
52
- gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
53
- bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
54
- bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
55
- bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
56
- bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
57
- bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
58
- bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
59
- bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
60
- bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
61
- });
62
-
63
- picocolors.exports = createColors();
64
- picocolors.exports.createColors = createColors;
65
-
66
- var c = picocolors.exports;
67
-
68
- function normalizeWindowsPath(input = "") {
69
- if (!input.includes("\\")) {
70
- return input;
71
- }
72
- return input.replace(/\\/g, "/");
73
- }
74
-
75
- const _UNC_REGEX = /^[/][/]/;
76
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
77
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
78
- const sep = "/";
79
- const delimiter = ":";
80
- const normalize = function(path2) {
81
- if (path2.length === 0) {
82
- return ".";
83
- }
84
- path2 = normalizeWindowsPath(path2);
85
- const isUNCPath = path2.match(_UNC_REGEX);
86
- const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
87
- const isPathAbsolute = isAbsolute(path2);
88
- const trailingSeparator = path2[path2.length - 1] === "/";
89
- path2 = normalizeString(path2, !isPathAbsolute);
90
- if (path2.length === 0) {
91
- if (isPathAbsolute) {
92
- return "/";
93
- }
94
- return trailingSeparator ? "./" : ".";
95
- }
96
- if (trailingSeparator) {
97
- path2 += "/";
98
- }
99
- if (isUNCPath) {
100
- if (hasUNCDrive) {
101
- return `//./${path2}`;
102
- }
103
- return `//${path2}`;
104
- }
105
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
106
- };
107
- const join = function(...args) {
108
- if (args.length === 0) {
109
- return ".";
110
- }
111
- let joined;
112
- for (let i = 0; i < args.length; ++i) {
113
- const arg = args[i];
114
- if (arg.length > 0) {
115
- if (joined === void 0) {
116
- joined = arg;
117
- } else {
118
- joined += `/${arg}`;
119
- }
120
- }
121
- }
122
- if (joined === void 0) {
123
- return ".";
124
- }
125
- return normalize(joined);
126
- };
127
- const resolve = function(...args) {
128
- args = args.map((arg) => normalizeWindowsPath(arg));
129
- let resolvedPath = "";
130
- let resolvedAbsolute = false;
131
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
132
- const path2 = i >= 0 ? args[i] : process.cwd();
133
- if (path2.length === 0) {
134
- continue;
135
- }
136
- resolvedPath = `${path2}/${resolvedPath}`;
137
- resolvedAbsolute = isAbsolute(path2);
138
- }
139
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
140
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
141
- return `/${resolvedPath}`;
142
- }
143
- return resolvedPath.length > 0 ? resolvedPath : ".";
144
- };
145
- function normalizeString(path2, allowAboveRoot) {
146
- let res = "";
147
- let lastSegmentLength = 0;
148
- let lastSlash = -1;
149
- let dots = 0;
150
- let char = null;
151
- for (let i = 0; i <= path2.length; ++i) {
152
- if (i < path2.length) {
153
- char = path2[i];
154
- } else if (char === "/") {
155
- break;
156
- } else {
157
- char = "/";
158
- }
159
- if (char === "/") {
160
- if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
161
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
162
- if (res.length > 2) {
163
- const lastSlashIndex = res.lastIndexOf("/");
164
- if (lastSlashIndex === -1) {
165
- res = "";
166
- lastSegmentLength = 0;
167
- } else {
168
- res = res.slice(0, lastSlashIndex);
169
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
170
- }
171
- lastSlash = i;
172
- dots = 0;
173
- continue;
174
- } else if (res.length !== 0) {
175
- res = "";
176
- lastSegmentLength = 0;
177
- lastSlash = i;
178
- dots = 0;
179
- continue;
180
- }
181
- }
182
- if (allowAboveRoot) {
183
- res += res.length > 0 ? "/.." : "..";
184
- lastSegmentLength = 2;
185
- }
186
- } else {
187
- if (res.length > 0) {
188
- res += `/${path2.slice(lastSlash + 1, i)}`;
189
- } else {
190
- res = path2.slice(lastSlash + 1, i);
191
- }
192
- lastSegmentLength = i - lastSlash - 1;
193
- }
194
- lastSlash = i;
195
- dots = 0;
196
- } else if (char === "." && dots !== -1) {
197
- ++dots;
198
- } else {
199
- dots = -1;
200
- }
201
- }
202
- return res;
203
- }
204
- const isAbsolute = function(p) {
205
- return _IS_ABSOLUTE_RE.test(p);
206
- };
207
- const toNamespacedPath = function(p) {
208
- return normalizeWindowsPath(p);
209
- };
210
- const extname = function(p) {
211
- return path.posix.extname(normalizeWindowsPath(p));
212
- };
213
- const relative = function(from, to) {
214
- return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
215
- };
216
- const dirname = function(p) {
217
- return path.posix.dirname(normalizeWindowsPath(p));
218
- };
219
- const format = function(p) {
220
- return normalizeWindowsPath(path.posix.format(p));
221
- };
222
- const basename = function(p, ext) {
223
- return path.posix.basename(normalizeWindowsPath(p), ext);
224
- };
225
- const parse = function(p) {
226
- return path.posix.parse(normalizeWindowsPath(p));
227
- };
228
-
229
- const _path = /*#__PURE__*/Object.freeze({
230
- __proto__: null,
231
- sep: sep,
232
- delimiter: delimiter,
233
- normalize: normalize,
234
- join: join,
235
- resolve: resolve,
236
- normalizeString: normalizeString,
237
- isAbsolute: isAbsolute,
238
- toNamespacedPath: toNamespacedPath,
239
- extname: extname,
240
- relative: relative,
241
- dirname: dirname,
242
- format: format,
243
- basename: basename,
244
- parse: parse
245
- });
246
-
247
- const index = {
248
- ..._path
249
- };
250
-
251
- function toArray(array) {
252
- array = array || [];
253
- if (Array.isArray(array))
254
- return array;
255
- return [array];
256
- }
257
- function notNullish(v) {
258
- return v != null;
259
- }
260
- function slash(str) {
261
- return str.replace(/\\/g, "/");
262
- }
263
- const noop = () => {
264
- };
265
- function partitionSuiteChildren(suite) {
266
- let tasksGroup = [];
267
- const tasksGroups = [];
268
- for (const c2 of suite.tasks) {
269
- if (tasksGroup.length === 0 || c2.computeMode === tasksGroup[0].computeMode) {
270
- tasksGroup.push(c2);
271
- } else {
272
- tasksGroups.push(tasksGroup);
273
- tasksGroup = [c2];
274
- }
275
- }
276
- if (tasksGroup.length > 0)
277
- tasksGroups.push(tasksGroup);
278
- return tasksGroups;
279
- }
280
- function interpretOnlyMode(tasks) {
281
- if (tasks.some((t) => t.mode === "only")) {
282
- tasks.forEach((t) => {
283
- if (t.mode === "run")
284
- t.mode = "skip";
285
- else if (t.mode === "only")
286
- t.mode = "run";
287
- });
288
- }
289
- tasks.forEach((t) => {
290
- if (t.type === "suite") {
291
- if (t.mode === "skip")
292
- t.tasks.forEach((c2) => c2.mode === "run" && (c2.mode = "skip"));
293
- else
294
- interpretOnlyMode(t.tasks);
295
- }
296
- });
297
- }
298
- function getTests(suite) {
299
- return toArray(suite).flatMap((s) => s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
300
- }
301
- function getTasks(tasks) {
302
- return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
303
- }
304
- function getSuites(suite) {
305
- return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
306
- }
307
- function hasTests(suite) {
308
- return toArray(suite).some((s) => s.tasks.some((c2) => c2.type === "test" || hasTests(c2)));
309
- }
310
- function hasFailed(suite) {
311
- return toArray(suite).some((s) => {
312
- var _a;
313
- return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
314
- });
315
- }
316
- function getNames(task) {
317
- const names = [task.name];
318
- let current = task;
319
- while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
320
- current = current.suite || current.file;
321
- if (current == null ? void 0 : current.name)
322
- names.unshift(current.name);
323
- }
324
- return names;
325
- }
326
- async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
327
- if (isPackageExists(dependency))
328
- return true;
329
- console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
330
- `));
331
- if (!promptInstall)
332
- return false;
333
- const prompts = await import('./index-fa899e66.js').then(function (n) { return n.i; });
334
- const { install } = await prompts.prompt({
335
- type: "confirm",
336
- name: "install",
337
- message: c.reset(`Do you want to install ${c.green(dependency)}?`)
338
- });
339
- if (install) {
340
- await (await import('./index-0c3a317d.js')).installPackage(dependency, { dev: true });
341
- return true;
342
- }
343
- return false;
344
- }
345
-
346
- export { getTests as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getNames as g, resolve as h, isAbsolute as i, hasFailed as j, notNullish as k, index as l, interpretOnlyMode as m, noop as n, hasTests as o, partitionSuiteChildren as p, getTasks as q, relative as r, slash as s, toArray as t };