@reporters/github 1.5.0 → 1.5.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.
- package/index.js +12 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,13 +10,19 @@ const stack = new StackUtils({ cwd: WORKSPACE, internals: StackUtils.nodeInterna
|
|
|
10
10
|
|
|
11
11
|
const isFile = (name) => name?.startsWith(WORKSPACE);
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const getRelativeFilePath = (name) => (isFile(name) ? path.relative(WORKSPACE, require.resolve(name) ?? '') : null);
|
|
14
|
+
|
|
15
|
+
function getFilePath(fileName) {
|
|
16
|
+
if (fileName.startsWith('file://')) {
|
|
17
|
+
return getRelativeFilePath(new URL(fileName).pathname);
|
|
18
|
+
}
|
|
19
|
+
return getRelativeFilePath(fileName);
|
|
20
|
+
}
|
|
14
21
|
|
|
15
22
|
const parseStack = (error, file) => {
|
|
16
23
|
const err = error?.code === 'ERR_TEST_FAILURE' ? error?.cause : error;
|
|
17
24
|
const stackLines = (err?.stack ?? '').split(/\r?\n/);
|
|
18
25
|
const line = stackLines.find((l) => l.includes(file)) ?? stackLines[0];
|
|
19
|
-
|
|
20
26
|
return line ? stack.parseLine(line) : null;
|
|
21
27
|
};
|
|
22
28
|
|
|
@@ -59,9 +65,11 @@ module.exports = async function githubReporter(source) {
|
|
|
59
65
|
// no need to re-annotate the file itself
|
|
60
66
|
break;
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
let filePath = getFilePath(event.data.file);
|
|
69
|
+
const location = parseStack(error, filePath);
|
|
70
|
+
filePath = getFilePath(location?.file ?? filePath) ?? filePath;
|
|
63
71
|
core.error(util.inspect(error, { colors: false, breakLength: Infinity }), {
|
|
64
|
-
file:
|
|
72
|
+
file: filePath,
|
|
65
73
|
startLine: location?.line,
|
|
66
74
|
startColumn: location?.column,
|
|
67
75
|
title: event.data.name,
|