@wdio/json-reporter 10.0.0-alpha.18 → 10.0.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.
- package/build/mergeResults.cjs +32 -12
- package/build/mergeResults.d.ts.map +1 -1
- package/build/mergeResults.js +32 -12
- package/package.json +6 -6
package/build/mergeResults.cjs
CHANGED
|
@@ -43,16 +43,17 @@ async function mergeResults(dir = process.argv[2], filePattern = process.argv[3]
|
|
|
43
43
|
if (!doesDirExist) {
|
|
44
44
|
throw new Error(`Directory "${dir}" does not exist.`);
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
await import_promises.default.writeFile(filePath, JSON.stringify(mergedResults));
|
|
46
|
+
const fileName = customFileName || DEFAULT_FILENAME;
|
|
47
|
+
const filePath = import_node_path.default.join(dir, fileName);
|
|
48
|
+
const rawData = await getDataFromFiles(dir, filePattern, import_node_path.default.basename(fileName));
|
|
49
|
+
if (rawData.length === 0 && await outputFileParses(filePath)) {
|
|
50
|
+
return {};
|
|
52
51
|
}
|
|
52
|
+
const mergedResults = mergeData(rawData);
|
|
53
|
+
await import_promises.default.writeFile(filePath, JSON.stringify(mergedResults));
|
|
53
54
|
return mergedResults;
|
|
54
55
|
}
|
|
55
|
-
async function getDataFromFiles(dir, filePattern) {
|
|
56
|
+
async function getDataFromFiles(dir, filePattern, outputFileName) {
|
|
56
57
|
let safePattern;
|
|
57
58
|
if (filePattern instanceof RegExp) {
|
|
58
59
|
safePattern = (0, import_safe_regex2.default)(filePattern) ? filePattern : /\.json$/;
|
|
@@ -66,11 +67,30 @@ async function getDataFromFiles(dir, filePattern) {
|
|
|
66
67
|
safePattern = /\.json$/;
|
|
67
68
|
}
|
|
68
69
|
const fileNames = (await import_promises.default.readdir(dir)).filter((file) => file.match(safePattern));
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const entries = (await Promise.all(fileNames.map(async (fileName) => {
|
|
71
|
+
const raw = (await import_promises.default.readFile(import_node_path.default.join(dir, fileName))).toString();
|
|
72
|
+
try {
|
|
73
|
+
const contents = JSON.parse(raw);
|
|
74
|
+
return { fileName, contents };
|
|
75
|
+
} catch (err) {
|
|
76
|
+
if (fileName === outputFileName) {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
}))).filter((entry) => entry !== void 0);
|
|
82
|
+
return entries.filter(({ fileName, contents }) => !(fileName === outputFileName && Array.isArray(contents.capabilities))).map(({ contents }) => contents);
|
|
83
|
+
}
|
|
84
|
+
async function outputFileParses(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
JSON.parse((await import_promises.default.readFile(filePath)).toString());
|
|
87
|
+
return true;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (err.code === "ENOENT" || err instanceof SyntaxError) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
function mergeData(rawData) {
|
|
76
96
|
if (rawData.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeResults.d.ts","sourceRoot":"","sources":["../src/mergeResults.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI3C,KAAK,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,CAAA;CAAE,CAAA;AAEtG,wBAA8B,YAAY,CACtC,GAAG,GAAE,MAAwB,EAC7B,WAAW,GAAE,MAAM,GAAG,MAAwB,EAC9C,cAAc,GAAE,MAAwB,
|
|
1
|
+
{"version":3,"file":"mergeResults.d.ts","sourceRoot":"","sources":["../src/mergeResults.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI3C,KAAK,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,CAAA;CAAE,CAAA;AAEtG,wBAA8B,YAAY,CACtC,GAAG,GAAE,MAAwB,EAC7B,WAAW,GAAE,MAAM,GAAG,MAAwB,EAC9C,cAAc,GAAE,MAAwB,4BAqB3C"}
|
package/build/mergeResults.js
CHANGED
|
@@ -8,16 +8,17 @@ async function mergeResults(dir = process.argv[2], filePattern = process.argv[3]
|
|
|
8
8
|
if (!doesDirExist) {
|
|
9
9
|
throw new Error(`Directory "${dir}" does not exist.`);
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
await fs.writeFile(filePath, JSON.stringify(mergedResults));
|
|
11
|
+
const fileName = customFileName || DEFAULT_FILENAME;
|
|
12
|
+
const filePath = path.join(dir, fileName);
|
|
13
|
+
const rawData = await getDataFromFiles(dir, filePattern, path.basename(fileName));
|
|
14
|
+
if (rawData.length === 0 && await outputFileParses(filePath)) {
|
|
15
|
+
return {};
|
|
17
16
|
}
|
|
17
|
+
const mergedResults = mergeData(rawData);
|
|
18
|
+
await fs.writeFile(filePath, JSON.stringify(mergedResults));
|
|
18
19
|
return mergedResults;
|
|
19
20
|
}
|
|
20
|
-
async function getDataFromFiles(dir, filePattern) {
|
|
21
|
+
async function getDataFromFiles(dir, filePattern, outputFileName) {
|
|
21
22
|
let safePattern;
|
|
22
23
|
if (filePattern instanceof RegExp) {
|
|
23
24
|
safePattern = safeRegexTest(filePattern) ? filePattern : /\.json$/;
|
|
@@ -31,11 +32,30 @@ async function getDataFromFiles(dir, filePattern) {
|
|
|
31
32
|
safePattern = /\.json$/;
|
|
32
33
|
}
|
|
33
34
|
const fileNames = (await fs.readdir(dir)).filter((file) => file.match(safePattern));
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const entries = (await Promise.all(fileNames.map(async (fileName) => {
|
|
36
|
+
const raw = (await fs.readFile(path.join(dir, fileName))).toString();
|
|
37
|
+
try {
|
|
38
|
+
const contents = JSON.parse(raw);
|
|
39
|
+
return { fileName, contents };
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (fileName === outputFileName) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}))).filter((entry) => entry !== void 0);
|
|
47
|
+
return entries.filter(({ fileName, contents }) => !(fileName === outputFileName && Array.isArray(contents.capabilities))).map(({ contents }) => contents);
|
|
48
|
+
}
|
|
49
|
+
async function outputFileParses(filePath) {
|
|
50
|
+
try {
|
|
51
|
+
JSON.parse((await fs.readFile(filePath)).toString());
|
|
52
|
+
return true;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
if (err.code === "ENOENT" || err instanceof SyntaxError) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
39
59
|
}
|
|
40
60
|
function mergeData(rawData) {
|
|
41
61
|
if (rawData.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/json-reporter",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "A WebdriverIO plugin to report results in json format.",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-json-reporter",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=22.19.0"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"types": "./build/index.d.ts",
|
|
38
|
-
"typeScriptVersion": "
|
|
38
|
+
"typeScriptVersion": "6.0.3",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@wdio/reporter": "10.0.0
|
|
41
|
-
"@wdio/types": "10.0.0
|
|
40
|
+
"@wdio/reporter": "10.0.0",
|
|
41
|
+
"@wdio/types": "10.0.0",
|
|
42
42
|
"safe-regex2": "^5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "38bd5ff4dccfaadccce4bd678286f00594623da2"
|
|
48
48
|
}
|