vitest 0.21.0 → 0.22.1

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.
Files changed (45) hide show
  1. package/LICENSE.md +61 -4
  2. package/dist/browser.d.ts +4 -5
  3. package/dist/browser.mjs +9 -9
  4. package/dist/{chunk-api-setup.89eb0e7a.mjs → chunk-api-setup.377c28aa.mjs} +9 -9
  5. package/dist/chunk-constants.71e8a211.mjs +284 -0
  6. package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
  7. package/dist/{chunk-defaults.8390340d.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
  8. package/dist/{chunk-integrations-globals.a798d352.mjs → chunk-integrations-globals.60af7da3.mjs} +8 -8
  9. package/dist/{chunk-mock-date.ea3b3121.mjs → chunk-mock-date.304e29b1.mjs} +11 -255
  10. package/dist/chunk-node-git.9a7e3153.mjs +78 -0
  11. package/dist/{chunk-runtime-chain.44b4224d.mjs → chunk-runtime-chain.be610650.mjs} +4 -3
  12. package/dist/{chunk-runtime-error.95e53764.mjs → chunk-runtime-error.1104e45a.mjs} +13 -12
  13. package/dist/{chunk-runtime-hooks.291644ec.mjs → chunk-runtime-hooks.5d7073db.mjs} +3 -3
  14. package/dist/{chunk-runtime-mocker.6190d6a3.mjs → chunk-runtime-mocker.49d21aa6.mjs} +19 -5
  15. package/dist/{chunk-runtime-rpc.fc50dcc0.mjs → chunk-runtime-rpc.57586b73.mjs} +1 -1
  16. package/dist/{chunk-utils-source-map.d307e4ea.mjs → chunk-utils-source-map.bbf3ad19.mjs} +2 -1
  17. package/dist/{chunk-vite-node-client.b59ba135.mjs → chunk-vite-node-client.cddda63d.mjs} +49 -21
  18. package/dist/{chunk-vite-node-debug.dbce2e1f.mjs → chunk-vite-node-debug.536c4c5b.mjs} +3 -3
  19. package/dist/{chunk-vite-node-externalize.80bed9b3.mjs → chunk-vite-node-externalize.c843f497.mjs} +186 -50
  20. package/dist/chunk-vite-node-utils.b432150c.mjs +6921 -0
  21. package/dist/cli-wrapper.mjs +124 -0
  22. package/dist/cli.mjs +16 -15
  23. package/dist/config.cjs +3 -0
  24. package/dist/config.d.ts +6 -3
  25. package/dist/config.mjs +2 -1
  26. package/dist/entry.mjs +9 -9
  27. package/dist/{global-644546f7.d.ts → global-fe52f84b.d.ts} +512 -177
  28. package/dist/{index-3f764034.d.ts → index-ea17aa0c.d.ts} +4 -52
  29. package/dist/index.d.ts +5 -6
  30. package/dist/index.mjs +7 -5
  31. package/dist/loader.mjs +4 -3
  32. package/dist/node.d.ts +3 -3
  33. package/dist/node.mjs +16 -15
  34. package/dist/suite.mjs +6 -4
  35. package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
  36. package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
  37. package/dist/vendor-index.9d9196cc.mjs +61 -0
  38. package/dist/{vendor-index.de788b6a.mjs → vendor-index.ae96af6e.mjs} +14 -14
  39. package/dist/{chunk-node-git.e0dc0a7e.mjs → vendor-index.fbec8a81.mjs} +5 -73
  40. package/dist/worker.mjs +9 -9
  41. package/package.json +9 -13
  42. package/vitest.mjs +1 -1
  43. package/dist/chunk-constants.9da1ef26.mjs +0 -38
  44. package/dist/chunk-vite-node-utils.96438e82.mjs +0 -1114
  45. package/dist/mocker-5e2a8e41.d.ts +0 -3
@@ -1,7 +1,3 @@
1
- import { existsSync, promises } from 'fs';
2
- import { createRequire } from 'module';
3
- import _url from 'url';
4
- import { t as toArray, y as resolve } from './chunk-mock-date.ea3b3121.mjs';
5
1
  import { importModule } from 'local-pkg';
6
2
 
7
3
  /*
@@ -139,156 +135,31 @@ function pLimit(concurrency) {
139
135
  return generator;
140
136
  }
141
137
 
142
- const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
143
- const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
144
- const defaultCoverageExcludes = [
145
- "coverage/**",
146
- "dist/**",
147
- "packages/*/test{,s}/**",
148
- "**/*.d.ts",
149
- "cypress/**",
150
- "test{,s}/**",
151
- "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
152
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
153
- "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
154
- "**/__tests__/**",
155
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
156
- "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
157
- ];
158
- const coverageConfigDefaults = {
159
- enabled: false,
160
- clean: true,
161
- cleanOnRerun: false,
162
- reportsDirectory: "./coverage",
163
- excludeNodeModules: true,
164
- exclude: defaultCoverageExcludes,
165
- reporter: ["text", "html", "clover"],
166
- allowExternal: false,
167
- extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
168
- };
169
- const fakeTimersDefaults = {
170
- loopLimit: 1e4,
171
- shouldClearNativeTimers: true,
172
- toFake: [
173
- "setTimeout",
174
- "clearTimeout",
175
- "setInterval",
176
- "clearInterval",
177
- "setImmediate",
178
- "clearImmediate",
179
- "Date"
180
- ]
138
+ const CoverageProviderMap = {
139
+ c8: "@vitest/coverage-c8",
140
+ istanbul: "@vitest/coverage-istanbul"
181
141
  };
182
- const config = {
183
- allowOnly: !process.env.CI,
184
- watch: !process.env.CI,
185
- globals: false,
186
- environment: "node",
187
- threads: true,
188
- clearMocks: false,
189
- restoreMocks: false,
190
- mockReset: false,
191
- include: defaultInclude,
192
- exclude: defaultExclude,
193
- testTimeout: 5e3,
194
- hookTimeout: 1e4,
195
- teardownTimeout: 1e3,
196
- isolate: true,
197
- watchExclude: ["**/node_modules/**", "**/dist/**"],
198
- forceRerunTriggers: [
199
- "**/package.json/**",
200
- "**/vitest.config.*/**",
201
- "**/vite.config.*/**"
202
- ],
203
- update: false,
204
- reporters: [],
205
- silent: false,
206
- api: false,
207
- ui: false,
208
- uiBase: "/__vitest__/",
209
- open: true,
210
- css: {
211
- include: [/\.module\./]
212
- },
213
- coverage: coverageConfigDefaults,
214
- fakeTimers: fakeTimersDefaults,
215
- maxConcurrency: 5,
216
- dangerouslyIgnoreUnhandledErrors: false
217
- };
218
- const configDefaults = Object.freeze(config);
219
-
220
- function resolveC8Options(options, root) {
221
- const resolved = {
222
- ...configDefaults.coverage,
223
- ...options
224
- };
225
- resolved.reporter = toArray(resolved.reporter);
226
- resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
227
- resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
228
- return resolved;
229
- }
230
- async function cleanCoverage(options, clean = true) {
231
- if (clean && existsSync(options.reportsDirectory))
232
- await promises.rm(options.reportsDirectory, { recursive: true, force: true });
233
- if (!existsSync(options.tempDirectory))
234
- await promises.mkdir(options.tempDirectory, { recursive: true });
142
+ async function resolveCoverageProvider(provider) {
143
+ if (typeof provider === "string") {
144
+ const pkg = CoverageProviderMap[provider];
145
+ if (!pkg)
146
+ throw new Error(`Unknown coverage provider: ${provider}`);
147
+ return await importModule(pkg);
148
+ } else {
149
+ return provider;
150
+ }
235
151
  }
236
- const require = createRequire(import.meta.url);
237
- function takeCoverage() {
238
- const v8 = require("v8");
239
- if (v8.takeCoverage == null)
240
- console.warn("[Vitest] takeCoverage is not available in this NodeJs version.\nCoverage could be incomplete. Update to NodeJs 14.18.");
241
- else
242
- v8.takeCoverage();
152
+ async function getCoverageProvider(options) {
153
+ if ((options == null ? void 0 : options.enabled) && (options == null ? void 0 : options.provider)) {
154
+ const { getProvider } = await resolveCoverageProvider(options.provider);
155
+ return await getProvider();
156
+ }
157
+ return null;
243
158
  }
244
- async function reportCoverage(ctx) {
245
- takeCoverage();
246
- const createReport = require("c8/lib/report");
247
- const report = createReport(ctx.config.coverage);
248
- const sourceMapMeta = {};
249
- await Promise.all(Array.from(ctx.vitenode.fetchCache.entries()).filter((i) => !i[0].includes("/node_modules/")).map(async ([file, { result }]) => {
250
- const map = result.map;
251
- if (!map)
252
- return;
253
- const url = _url.pathToFileURL(file).href;
254
- let code;
255
- try {
256
- code = (await promises.readFile(file)).toString();
257
- } catch {
258
- }
259
- const sources = [url];
260
- sourceMapMeta[url] = {
261
- source: result.code,
262
- map: {
263
- sourcesContent: code ? [code] : void 0,
264
- ...map,
265
- sources
266
- }
267
- };
268
- }));
269
- const offset = 224;
270
- report._getSourceMap = (coverage) => {
271
- const path = _url.pathToFileURL(coverage.url).href;
272
- const data = sourceMapMeta[path];
273
- if (!data)
274
- return {};
275
- return {
276
- sourceMap: {
277
- sourcemap: data.map
278
- },
279
- source: Array(offset).fill(".").join("") + data.source
280
- };
281
- };
282
- await report.run();
283
- if (ctx.config.coverage.enabled) {
284
- if (ctx.config.coverage["100"]) {
285
- ctx.config.coverage.lines = 100;
286
- ctx.config.coverage.functions = 100;
287
- ctx.config.coverage.branches = 100;
288
- ctx.config.coverage.statements = 100;
289
- }
290
- const { checkCoverages } = require("c8/lib/commands/check-coverage");
291
- await checkCoverages(ctx.config.coverage, report);
159
+ async function takeCoverageInsideWorker(options) {
160
+ if (options.enabled && options.provider) {
161
+ const { takeCoverage } = await resolveCoverageProvider(options.provider);
162
+ return await (takeCoverage == null ? void 0 : takeCoverage());
292
163
  }
293
164
  }
294
165
 
@@ -677,4 +548,4 @@ const envPackageNames = {
677
548
  "edge-runtime": "@edge-runtime/vm"
678
549
  };
679
550
 
680
- export { cleanCoverage as a, reportCoverage as b, configDefaults as c, envPackageNames as d, environments as e, envs as f, pLimit as p, resolveC8Options as r, takeCoverage as t };
551
+ export { CoverageProviderMap as C, envPackageNames as a, envs as b, environments as e, getCoverageProvider as g, pLimit as p, takeCoverageInsideWorker as t };
@@ -1,19 +1,19 @@
1
- import { g as globalApis } from './chunk-constants.9da1ef26.mjs';
2
- import { i as index } from './chunk-runtime-hooks.291644ec.mjs';
1
+ import { k as globalApis } from './chunk-constants.71e8a211.mjs';
2
+ import { i as index } from './chunk-runtime-hooks.5d7073db.mjs';
3
+ import 'tty';
3
4
  import 'url';
4
- import './chunk-mock-date.ea3b3121.mjs';
5
5
  import 'path';
6
- import 'tty';
7
- import 'local-pkg';
8
- import './chunk-runtime-chain.44b4224d.mjs';
6
+ import './chunk-runtime-chain.be610650.mjs';
9
7
  import 'util';
8
+ import './chunk-mock-date.304e29b1.mjs';
9
+ import 'local-pkg';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.fc50dcc0.mjs';
12
+ import './chunk-runtime-rpc.57586b73.mjs';
13
13
  import './chunk-utils-global.fa20c2f6.mjs';
14
14
  import './chunk-utils-timers.b48455ed.mjs';
15
15
  import 'fs';
16
- import './chunk-utils-source-map.d307e4ea.mjs';
16
+ import './chunk-utils-source-map.bbf3ad19.mjs';
17
17
  import './spy.mjs';
18
18
  import 'tinyspy';
19
19
 
@@ -1,251 +1,7 @@
1
- import path, { relative as relative$1 } from 'path';
2
- import require$$0 from 'tty';
1
+ import { relative } from 'path';
2
+ import { r as relative$1, p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.71e8a211.mjs';
3
3
  import { isPackageExists } from 'local-pkg';
4
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
- function normalizeWindowsPath(input = "") {
67
- if (!input.includes("\\")) {
68
- return input;
69
- }
70
- return input.replace(/\\/g, "/");
71
- }
72
-
73
- const _UNC_REGEX = /^[/][/]/;
74
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
75
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
76
- const sep = "/";
77
- const delimiter = ":";
78
- const normalize = function(path2) {
79
- if (path2.length === 0) {
80
- return ".";
81
- }
82
- path2 = normalizeWindowsPath(path2);
83
- const isUNCPath = path2.match(_UNC_REGEX);
84
- const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
85
- const isPathAbsolute = isAbsolute(path2);
86
- const trailingSeparator = path2[path2.length - 1] === "/";
87
- path2 = normalizeString(path2, !isPathAbsolute);
88
- if (path2.length === 0) {
89
- if (isPathAbsolute) {
90
- return "/";
91
- }
92
- return trailingSeparator ? "./" : ".";
93
- }
94
- if (trailingSeparator) {
95
- path2 += "/";
96
- }
97
- if (isUNCPath) {
98
- if (hasUNCDrive) {
99
- return `//./${path2}`;
100
- }
101
- return `//${path2}`;
102
- }
103
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
104
- };
105
- const join = function(...args) {
106
- if (args.length === 0) {
107
- return ".";
108
- }
109
- let joined;
110
- for (let i = 0; i < args.length; ++i) {
111
- const arg = args[i];
112
- if (arg.length > 0) {
113
- if (joined === void 0) {
114
- joined = arg;
115
- } else {
116
- joined += `/${arg}`;
117
- }
118
- }
119
- }
120
- if (joined === void 0) {
121
- return ".";
122
- }
123
- return normalize(joined);
124
- };
125
- const resolve = function(...args) {
126
- args = args.map((arg) => normalizeWindowsPath(arg));
127
- let resolvedPath = "";
128
- let resolvedAbsolute = false;
129
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
130
- const path2 = i >= 0 ? args[i] : process.cwd();
131
- if (path2.length === 0) {
132
- continue;
133
- }
134
- resolvedPath = `${path2}/${resolvedPath}`;
135
- resolvedAbsolute = isAbsolute(path2);
136
- }
137
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
138
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
139
- return `/${resolvedPath}`;
140
- }
141
- return resolvedPath.length > 0 ? resolvedPath : ".";
142
- };
143
- function normalizeString(path2, allowAboveRoot) {
144
- let res = "";
145
- let lastSegmentLength = 0;
146
- let lastSlash = -1;
147
- let dots = 0;
148
- let char = null;
149
- for (let i = 0; i <= path2.length; ++i) {
150
- if (i < path2.length) {
151
- char = path2[i];
152
- } else if (char === "/") {
153
- break;
154
- } else {
155
- char = "/";
156
- }
157
- if (char === "/") {
158
- if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
159
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
160
- if (res.length > 2) {
161
- const lastSlashIndex = res.lastIndexOf("/");
162
- if (lastSlashIndex === -1) {
163
- res = "";
164
- lastSegmentLength = 0;
165
- } else {
166
- res = res.slice(0, lastSlashIndex);
167
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
168
- }
169
- lastSlash = i;
170
- dots = 0;
171
- continue;
172
- } else if (res.length !== 0) {
173
- res = "";
174
- lastSegmentLength = 0;
175
- lastSlash = i;
176
- dots = 0;
177
- continue;
178
- }
179
- }
180
- if (allowAboveRoot) {
181
- res += res.length > 0 ? "/.." : "..";
182
- lastSegmentLength = 2;
183
- }
184
- } else {
185
- if (res.length > 0) {
186
- res += `/${path2.slice(lastSlash + 1, i)}`;
187
- } else {
188
- res = path2.slice(lastSlash + 1, i);
189
- }
190
- lastSegmentLength = i - lastSlash - 1;
191
- }
192
- lastSlash = i;
193
- dots = 0;
194
- } else if (char === "." && dots !== -1) {
195
- ++dots;
196
- } else {
197
- dots = -1;
198
- }
199
- }
200
- return res;
201
- }
202
- const isAbsolute = function(p) {
203
- return _IS_ABSOLUTE_RE.test(p);
204
- };
205
- const toNamespacedPath = function(p) {
206
- return normalizeWindowsPath(p);
207
- };
208
- const extname = function(p) {
209
- return path.posix.extname(normalizeWindowsPath(p));
210
- };
211
- const relative = function(from, to) {
212
- return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
213
- };
214
- const dirname = function(p) {
215
- return path.posix.dirname(normalizeWindowsPath(p));
216
- };
217
- const format = function(p) {
218
- return normalizeWindowsPath(path.posix.format(p));
219
- };
220
- const basename = function(p, ext) {
221
- return path.posix.basename(normalizeWindowsPath(p), ext);
222
- };
223
- const parse = function(p) {
224
- return path.posix.parse(normalizeWindowsPath(p));
225
- };
226
-
227
- const _path = /*#__PURE__*/Object.freeze({
228
- __proto__: null,
229
- sep: sep,
230
- delimiter: delimiter,
231
- normalize: normalize,
232
- join: join,
233
- resolve: resolve,
234
- normalizeString: normalizeString,
235
- isAbsolute: isAbsolute,
236
- toNamespacedPath: toNamespacedPath,
237
- extname: extname,
238
- relative: relative,
239
- dirname: dirname,
240
- format: format,
241
- basename: basename,
242
- parse: parse
243
- });
244
-
245
- ({
246
- ..._path
247
- });
248
-
249
5
  const RealDate = Date;
250
6
  let now = null;
251
7
  class MockDate extends RealDate {
@@ -381,9 +137,9 @@ function deepMerge(target, ...sources) {
381
137
  const source = sources.shift();
382
138
  if (source === void 0)
383
139
  return target;
384
- if (isMergableObject(target) && isMergableObject(source)) {
140
+ if (isMergeableObject(target) && isMergeableObject(source)) {
385
141
  Object.keys(source).forEach((key) => {
386
- if (isMergableObject(source[key])) {
142
+ if (isMergeableObject(source[key])) {
387
143
  if (!target[key])
388
144
  target[key] = {};
389
145
  deepMerge(target[key], source[key]);
@@ -394,7 +150,7 @@ function deepMerge(target, ...sources) {
394
150
  }
395
151
  return deepMerge(target, ...sources);
396
152
  }
397
- function isMergableObject(item) {
153
+ function isMergeableObject(item) {
398
154
  return isPlainObject(item) && !Array.isArray(item);
399
155
  }
400
156
  function assertTypes(value, name, types) {
@@ -459,7 +215,7 @@ var _a;
459
215
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
460
216
  const isBrowser = typeof window !== "undefined";
461
217
  const isWindows = isNode && process.platform === "win32";
462
- const relativePath = isBrowser ? relative$1 : relative;
218
+ const relativePath = isBrowser ? relative : relative$1;
463
219
  function partitionSuiteChildren(suite) {
464
220
  let tasksGroup = [];
465
221
  const tasksGroups = [];
@@ -500,18 +256,18 @@ async function ensurePackageInstalled(dependency, root) {
500
256
  `));
501
257
  if (!promptInstall)
502
258
  return false;
503
- const prompts = await import('./vendor-index.de788b6a.mjs').then(function (n) { return n.i; });
259
+ const prompts = await import('./vendor-index.ae96af6e.mjs').then(function (n) { return n.i; });
504
260
  const { install } = await prompts.prompt({
505
261
  type: "confirm",
506
262
  name: "install",
507
263
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
508
264
  });
509
265
  if (install) {
510
- await (await import('./chunk-install-pkg.6c6dc0c2.mjs')).installPackage(dependency, { dev: true });
266
+ await (await import('./chunk-install-pkg.3aa3eae6.mjs')).installPackage(dependency, { dev: true });
511
267
  process.stderr.write(picocolors.exports.yellow(`
512
268
  Package ${dependency} installed, re-run the command to start.
513
269
  `));
514
- process.exit(1);
270
+ process.exit(EXIT_CODE_RESTART);
515
271
  return true;
516
272
  }
517
273
  return false;
@@ -544,7 +300,7 @@ function getCallLastIndex(code) {
544
300
  }
545
301
  return null;
546
302
  }
547
- isNode ? relative : relative$1;
303
+ isNode ? relative$1 : relative;
548
304
  class AggregateErrorPonyfill extends Error {
549
305
  constructor(errors, message = "") {
550
306
  super(message);
@@ -552,4 +308,4 @@ class AggregateErrorPonyfill extends Error {
552
308
  }
553
309
  }
554
310
 
555
- export { AggregateErrorPonyfill as A, isAbsolute as B, relative as C, getTests as D, hasFailedSnapshot as E, getSuites as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getAllMockableProperties as O, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, picocolors as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, resolve as y, basename as z };
311
+ export { AggregateErrorPonyfill as A, stdout as B, isWindows as C, mergeSlashes as D, getAllMockableProperties as E, RealDate as R, resetModules as a, getNames as b, assertTypes as c, getFullName as d, notNullish as e, deepClone as f, getCallLastIndex as g, getType as h, isObject as i, isNode as j, relativePath as k, isBrowser as l, mockDate as m, noop as n, shuffle as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, getTests as v, hasFailedSnapshot as w, getSuites as x, deepMerge as y, ensurePackageInstalled as z };
@@ -0,0 +1,78 @@
1
+ import { a as resolve } from './chunk-constants.71e8a211.mjs';
2
+ import { e as execa } from './vendor-index.fbec8a81.mjs';
3
+ import 'tty';
4
+ import 'url';
5
+ import 'path';
6
+ import 'buffer';
7
+ import 'child_process';
8
+ import 'process';
9
+ import './vendor-index.2ae8040a.mjs';
10
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
11
+ import 'fs';
12
+ import 'stream';
13
+ import 'util';
14
+ import 'os';
15
+ import './vendor-index.29636037.mjs';
16
+ import 'assert';
17
+ import 'events';
18
+
19
+ class VitestGit {
20
+ constructor(cwd) {
21
+ this.cwd = cwd;
22
+ }
23
+ async resolveFilesWithGitCommand(args) {
24
+ let result;
25
+ try {
26
+ result = await execa("git", args, { cwd: this.root });
27
+ } catch (e) {
28
+ e.message = e.stderr;
29
+ throw e;
30
+ }
31
+ return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
32
+ }
33
+ async findChangedFiles(options) {
34
+ const root = await this.getRoot(this.cwd);
35
+ if (!root)
36
+ return null;
37
+ this.root = root;
38
+ const changedSince = options.changedSince;
39
+ if (typeof changedSince === "string") {
40
+ const [committed, staged2, unstaged2] = await Promise.all([
41
+ this.getFilesSince(changedSince),
42
+ this.getStagedFiles(),
43
+ this.getUnstagedFiles()
44
+ ]);
45
+ return [...committed, ...staged2, ...unstaged2];
46
+ }
47
+ const [staged, unstaged] = await Promise.all([
48
+ this.getStagedFiles(),
49
+ this.getUnstagedFiles()
50
+ ]);
51
+ return [...staged, ...unstaged];
52
+ }
53
+ getFilesSince(hash) {
54
+ return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
55
+ }
56
+ getStagedFiles() {
57
+ return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
58
+ }
59
+ getUnstagedFiles() {
60
+ return this.resolveFilesWithGitCommand([
61
+ "ls-files",
62
+ "--other",
63
+ "--modified",
64
+ "--exclude-standard"
65
+ ]);
66
+ }
67
+ async getRoot(cwd) {
68
+ const options = ["rev-parse", "--show-cdup"];
69
+ try {
70
+ const result = await execa("git", options, { cwd });
71
+ return resolve(cwd, result.stdout);
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ }
77
+
78
+ export { VitestGit };
@@ -1,11 +1,12 @@
1
1
  import util$1 from 'util';
2
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, p as picocolors, e as getFullName, n as noop } from './chunk-mock-date.ea3b3121.mjs';
2
+ import { i as isObject, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, d as getFullName, n as noop } from './chunk-mock-date.304e29b1.mjs';
3
3
  import * as chai$2 from 'chai';
4
4
  import { expect, AssertionError, util } from 'chai';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.fc50dcc0.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.57586b73.mjs';
7
7
  import fs, { promises } from 'fs';
8
- import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.d307e4ea.mjs';
8
+ import { j as join, d as dirname, p as picocolors } from './chunk-constants.71e8a211.mjs';
9
+ import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.bbf3ad19.mjs';
9
10
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
10
11
  import { isMockFunction } from './spy.mjs';
11
12
  import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';