monocart-coverage-reports 2.7.8 → 2.7.10

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,58 +1,58 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const Util = require('../utils/util.js');
4
- const { convertSourceMap } = require('../packages/monocart-coverage-vendor.js');
5
-
6
- function saveFile(url, source, dir) {
7
- if (!fs.existsSync(dir)) {
8
- fs.mkdirSync(dir, {
9
- recursive: true
10
- });
11
- }
12
-
13
- const id = Util.calculateSha1(url + source);
14
- const filePath = path.resolve(dir, `source-${id}.json`);
15
- if (!fs.existsSync(filePath)) {
16
- fs.writeFileSync(filePath, JSON.stringify({
17
- url,
18
- source
19
- }));
20
- }
21
-
22
- }
23
-
24
- function saveSource(url, loaded, dir) {
25
-
26
- // filter node modules
27
- if (url.startsWith('node:')) {
28
- return;
29
- }
30
-
31
- const { source, format } = loaded;
32
- if (typeof source !== 'string' || !['module', 'commonjs'].includes(format)) {
33
- // no source or wrong format
34
- return;
35
- }
36
-
37
- if (!convertSourceMap.mapFileCommentRegex.test(source)) {
38
- // no sourcemap
39
- return;
40
- }
41
-
42
- saveFile(url, source, dir);
43
-
44
- }
45
-
46
- async function load(url, context, nextLoad) {
47
- const loaded = await nextLoad(url, context);
48
- const dir = process.env.NODE_V8_COVERAGE;
49
- if (dir) {
50
- // only for coverage enabled
51
- saveSource(url, loaded, dir);
52
- }
53
- return loaded;
54
- }
55
-
56
- module.exports = {
57
- load
58
- };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const Util = require('../utils/util.js');
4
+ const { convertSourceMap } = require('../packages/monocart-coverage-vendor.js');
5
+
6
+ function saveFile(url, source, dir) {
7
+ if (!fs.existsSync(dir)) {
8
+ fs.mkdirSync(dir, {
9
+ recursive: true
10
+ });
11
+ }
12
+
13
+ const id = Util.calculateSha1(url + source);
14
+ const filePath = path.resolve(dir, `source-${id}.json`);
15
+ if (!fs.existsSync(filePath)) {
16
+ fs.writeFileSync(filePath, JSON.stringify({
17
+ url,
18
+ source
19
+ }));
20
+ }
21
+
22
+ }
23
+
24
+ function saveSource(url, loaded, dir) {
25
+
26
+ // filter node modules
27
+ if (url.startsWith('node:')) {
28
+ return;
29
+ }
30
+
31
+ const { source, format } = loaded;
32
+ if (typeof source !== 'string' || !['module', 'commonjs'].includes(format)) {
33
+ // no source or wrong format
34
+ return;
35
+ }
36
+
37
+ if (!convertSourceMap.mapFileCommentRegex.test(source)) {
38
+ // no sourcemap
39
+ return;
40
+ }
41
+
42
+ saveFile(url, source, dir);
43
+
44
+ }
45
+
46
+ async function load(url, context, nextLoad) {
47
+ const loaded = await nextLoad(url, context);
48
+ const dir = process.env.NODE_V8_COVERAGE;
49
+ if (dir) {
50
+ // only for coverage enabled
51
+ saveSource(url, loaded, dir);
52
+ }
53
+ return loaded;
54
+ }
55
+
56
+ module.exports = {
57
+ load
58
+ };
@@ -1,3 +1,3 @@
1
- import { load } from './hooks.js';
2
-
3
- export { load };
1
+ import { load } from './hooks.js';
2
+
3
+ export { load };
package/lib/utils/util.js CHANGED
@@ -128,8 +128,15 @@ const Util = {
128
128
  return htmlPathHandler();
129
129
  },
130
130
 
131
- resolveNodeModule: (p) => {
131
+ resolveNodeModule: (id) => {
132
132
 
133
+ // for deno npm module
134
+ const mp = require.resolve(id);
135
+ if (fs.existsSync(mp)) {
136
+ return mp;
137
+ }
138
+
139
+ const p = `${it}/dist/${it}.js`;
133
140
  // root
134
141
  const cwd = path.resolve('node_modules', p);
135
142
  if (fs.existsSync(cwd)) {
package/lib/v8/v8.js CHANGED
@@ -317,8 +317,8 @@ const handleV8HtmlReport = async (reportData, reportOptions, options) => {
317
317
  const htmlFile = path.basename(reportPath);
318
318
 
319
319
  // deps
320
- const jsFiles = ['monocart-code-viewer', 'monocart-formatter', 'turbogrid'].map((it) => {
321
- return Util.resolveNodeModule(`${it}/dist/${it}.js`);
320
+ const jsFiles = ['monocart-code-viewer', 'monocart-formatter', 'turbogrid'].map((id) => {
321
+ return Util.resolveNodeModule(id);
322
322
  });
323
323
 
324
324
  // package v8 ui
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-coverage-reports",
3
- "version": "2.7.8",
3
+ "version": "2.7.10",
4
4
  "description": "A code coverage tool to generate native V8 reports or Istanbul reports.",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -86,15 +86,15 @@
86
86
  "devDependencies": {
87
87
  "commander": "^12.0.0",
88
88
  "esbuild": "^0.20.2",
89
- "eslint": "^8.57.0",
90
- "eslint-config-plus": "^1.0.6",
91
- "eslint-plugin-html": "^8.0.0",
92
- "eslint-plugin-vue": "^9.24.0",
89
+ "eslint": "~9.1.1",
90
+ "eslint-config-plus": "^2.0.0",
91
+ "eslint-plugin-html": "^8.1.1",
92
+ "eslint-plugin-vue": "^9.25.0",
93
93
  "minimatch": "^9.0.4",
94
- "stylelint": "^16.3.1",
94
+ "stylelint": "^16.4.0",
95
95
  "stylelint-config-plus": "^1.1.0",
96
96
  "supports-color": "^9.4.0",
97
- "tsx": "^4.7.1",
98
- "ws": "^8.16.0"
97
+ "tsx": "^4.8.2",
98
+ "ws": "^8.17.0"
99
99
  }
100
100
  }