@vitest/coverage-istanbul 0.27.3 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  const COVERAGE_STORE_KEY = "__VITEST_COVERAGE__";
2
2
 
3
3
  async function getProvider() {
4
- const { IstanbulCoverageProvider } = await import('./provider-3a279f85.js');
4
+ const { IstanbulCoverageProvider } = await import('./provider-e9fe5ea1.js');
5
5
  return new IstanbulCoverageProvider();
6
6
  }
7
7
  function takeCoverage() {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { g as getProvider, t as takeCoverage } from './index-2807b0a4.js';
1
+ export { g as getProvider, t as takeCoverage } from './index-2345780c.js';
@@ -1,5 +1,4 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import path from 'path';
3
2
  import { defaultExclude, defaultInclude, coverageConfigDefaults } from 'vitest/config';
4
3
  import libReport from 'istanbul-lib-report';
5
4
  import reports from 'istanbul-reports';
@@ -7,78 +6,32 @@ import libCoverage from 'istanbul-lib-coverage';
7
6
  import libSourceMaps from 'istanbul-lib-source-maps';
8
7
  import { createInstrumenter } from 'istanbul-lib-instrument';
9
8
  import _TestExclude from 'test-exclude';
10
- import { C as COVERAGE_STORE_KEY } from './index-2807b0a4.js';
9
+ import { C as COVERAGE_STORE_KEY } from './index-2345780c.js';
11
10
 
12
11
  function normalizeWindowsPath(input = "") {
13
- if (!input.includes("\\")) {
12
+ if (!input || !input.includes("\\")) {
14
13
  return input;
15
14
  }
16
15
  return input.replace(/\\/g, "/");
17
16
  }
18
-
19
- const _UNC_REGEX = /^[/][/]/;
20
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
21
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
22
- const sep = "/";
23
- const delimiter = ":";
24
- const normalize = function(path2) {
25
- if (path2.length === 0) {
26
- return ".";
27
- }
28
- path2 = normalizeWindowsPath(path2);
29
- const isUNCPath = path2.match(_UNC_REGEX);
30
- const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
31
- const isPathAbsolute = isAbsolute(path2);
32
- const trailingSeparator = path2[path2.length - 1] === "/";
33
- path2 = normalizeString(path2, !isPathAbsolute);
34
- if (path2.length === 0) {
35
- if (isPathAbsolute) {
36
- return "/";
37
- }
38
- return trailingSeparator ? "./" : ".";
39
- }
40
- if (trailingSeparator) {
41
- path2 += "/";
42
- }
43
- if (isUNCPath) {
44
- if (hasUNCDrive) {
45
- return `//./${path2}`;
46
- }
47
- return `//${path2}`;
48
- }
49
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
50
- };
51
- const join = function(...args) {
52
- if (args.length === 0) {
53
- return ".";
54
- }
55
- let joined;
56
- for (let i = 0; i < args.length; ++i) {
57
- const arg = args[i];
58
- if (arg.length > 0) {
59
- if (joined === void 0) {
60
- joined = arg;
61
- } else {
62
- joined += `/${arg}`;
63
- }
64
- }
65
- }
66
- if (joined === void 0) {
67
- return ".";
17
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
18
+ function cwd() {
19
+ if (typeof process !== "undefined") {
20
+ return process.cwd().replace(/\\/g, "/");
68
21
  }
69
- return normalize(joined);
70
- };
71
- const resolve = function(...args) {
72
- args = args.map((arg) => normalizeWindowsPath(arg));
22
+ return "/";
23
+ }
24
+ const resolve = function(...arguments_) {
25
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
73
26
  let resolvedPath = "";
74
27
  let resolvedAbsolute = false;
75
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
76
- const path2 = i >= 0 ? args[i] : process.cwd();
77
- if (path2.length === 0) {
28
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
29
+ const path = index >= 0 ? arguments_[index] : cwd();
30
+ if (!path || path.length === 0) {
78
31
  continue;
79
32
  }
80
- resolvedPath = `${path2}/${resolvedPath}`;
81
- resolvedAbsolute = isAbsolute(path2);
33
+ resolvedPath = `${path}/${resolvedPath}`;
34
+ resolvedAbsolute = isAbsolute(path);
82
35
  }
83
36
  resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
84
37
  if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
@@ -86,22 +39,22 @@ const resolve = function(...args) {
86
39
  }
87
40
  return resolvedPath.length > 0 ? resolvedPath : ".";
88
41
  };
89
- function normalizeString(path2, allowAboveRoot) {
42
+ function normalizeString(path, allowAboveRoot) {
90
43
  let res = "";
91
44
  let lastSegmentLength = 0;
92
45
  let lastSlash = -1;
93
46
  let dots = 0;
94
47
  let char = null;
95
- for (let i = 0; i <= path2.length; ++i) {
96
- if (i < path2.length) {
97
- char = path2[i];
48
+ for (let index = 0; index <= path.length; ++index) {
49
+ if (index < path.length) {
50
+ char = path[index];
98
51
  } else if (char === "/") {
99
52
  break;
100
53
  } else {
101
54
  char = "/";
102
55
  }
103
56
  if (char === "/") {
104
- if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
57
+ if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
105
58
  if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
106
59
  if (res.length > 2) {
107
60
  const lastSlashIndex = res.lastIndexOf("/");
@@ -112,13 +65,13 @@ function normalizeString(path2, allowAboveRoot) {
112
65
  res = res.slice(0, lastSlashIndex);
113
66
  lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
114
67
  }
115
- lastSlash = i;
68
+ lastSlash = index;
116
69
  dots = 0;
117
70
  continue;
118
- } else if (res.length !== 0) {
71
+ } else if (res.length > 0) {
119
72
  res = "";
120
73
  lastSegmentLength = 0;
121
- lastSlash = i;
74
+ lastSlash = index;
122
75
  dots = 0;
123
76
  continue;
124
77
  }
@@ -129,13 +82,13 @@ function normalizeString(path2, allowAboveRoot) {
129
82
  }
130
83
  } else {
131
84
  if (res.length > 0) {
132
- res += `/${path2.slice(lastSlash + 1, i)}`;
85
+ res += `/${path.slice(lastSlash + 1, index)}`;
133
86
  } else {
134
- res = path2.slice(lastSlash + 1, i);
87
+ res = path.slice(lastSlash + 1, index);
135
88
  }
136
- lastSegmentLength = i - lastSlash - 1;
89
+ lastSegmentLength = index - lastSlash - 1;
137
90
  }
138
- lastSlash = i;
91
+ lastSlash = index;
139
92
  dots = 0;
140
93
  } else if (char === "." && dots !== -1) {
141
94
  ++dots;
@@ -148,50 +101,20 @@ function normalizeString(path2, allowAboveRoot) {
148
101
  const isAbsolute = function(p) {
149
102
  return _IS_ABSOLUTE_RE.test(p);
150
103
  };
151
- const toNamespacedPath = function(p) {
152
- return normalizeWindowsPath(p);
153
- };
154
- const extname = function(p) {
155
- return path.posix.extname(normalizeWindowsPath(p));
156
- };
157
104
  const relative = function(from, to) {
158
- return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
159
- };
160
- const dirname = function(p) {
161
- return path.posix.dirname(normalizeWindowsPath(p));
162
- };
163
- const format = function(p) {
164
- return normalizeWindowsPath(path.posix.format(p));
165
- };
166
- const basename = function(p, ext) {
167
- return path.posix.basename(normalizeWindowsPath(p), ext);
168
- };
169
- const parse = function(p) {
170
- return path.posix.parse(normalizeWindowsPath(p));
105
+ const _from = resolve(from).split("/");
106
+ const _to = resolve(to).split("/");
107
+ const _fromCopy = [..._from];
108
+ for (const segment of _fromCopy) {
109
+ if (_to[0] !== segment) {
110
+ break;
111
+ }
112
+ _from.shift();
113
+ _to.shift();
114
+ }
115
+ return [..._from.map(() => ".."), ..._to].join("/");
171
116
  };
172
117
 
173
- const _path = /*#__PURE__*/Object.freeze({
174
- __proto__: null,
175
- sep: sep,
176
- delimiter: delimiter,
177
- normalize: normalize,
178
- join: join,
179
- resolve: resolve,
180
- normalizeString: normalizeString,
181
- isAbsolute: isAbsolute,
182
- toNamespacedPath: toNamespacedPath,
183
- extname: extname,
184
- relative: relative,
185
- dirname: dirname,
186
- format: format,
187
- basename: basename,
188
- parse: parse
189
- });
190
-
191
- ({
192
- ..._path
193
- });
194
-
195
118
  class IstanbulCoverageProvider {
196
119
  constructor() {
197
120
  this.name = "istanbul";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-istanbul",
3
3
  "type": "module",
4
- "version": "0.27.3",
4
+ "version": "0.28.0",
5
5
  "description": "Istanbul coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "istanbul-lib-source-maps": "^4.0.1",
44
44
  "istanbul-reports": "^3.1.5",
45
45
  "test-exclude": "^6.0.0",
46
- "vitest": "0.27.3"
46
+ "vitest": "0.28.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/istanbul-lib-coverage": "^2.0.4",
@@ -51,7 +51,7 @@
51
51
  "@types/istanbul-lib-report": "^3.0.0",
52
52
  "@types/istanbul-lib-source-maps": "^4.0.1",
53
53
  "@types/istanbul-reports": "^3.0.1",
54
- "pathe": "^0.2.0"
54
+ "pathe": "^1.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "rimraf dist && rollup -c",