@reporters/github 1.9.2 → 1.9.3
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/gh_core.js +61 -0
- package/package.json +3 -2
package/gh_core.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// From Github Core SDK code
|
|
4
|
+
// eslint-disable-next-line import/no-unresolved
|
|
5
|
+
const coreUtils = require('@actions/core/lib/utils');
|
|
6
|
+
const { EOL } = require('node:os');
|
|
7
|
+
|
|
8
|
+
function escapeData(s) {
|
|
9
|
+
return coreUtils.toCommandValue(s)
|
|
10
|
+
.replace(/%/g, '%25')
|
|
11
|
+
.replace(/\r/g, '%0D')
|
|
12
|
+
.replace(/\n/g, '%0A');
|
|
13
|
+
}
|
|
14
|
+
function escapeProperty(s) {
|
|
15
|
+
return coreUtils.toCommandValue(s)
|
|
16
|
+
.replace(/%/g, '%25')
|
|
17
|
+
.replace(/\r/g, '%0D')
|
|
18
|
+
.replace(/\n/g, '%0A')
|
|
19
|
+
.replace(/:/g, '%3A')
|
|
20
|
+
.replace(/,/g, '%2C');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CMD_STRING = '::';
|
|
24
|
+
class Command {
|
|
25
|
+
constructor(command, properties, message, options = { EOL }) {
|
|
26
|
+
this.command = command ?? 'missing.command';
|
|
27
|
+
this.properties = properties;
|
|
28
|
+
this.message = message;
|
|
29
|
+
this.options = options;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
toString() {
|
|
33
|
+
let cmdStr = CMD_STRING + this.command;
|
|
34
|
+
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
35
|
+
cmdStr += ' ';
|
|
36
|
+
let first = true;
|
|
37
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
38
|
+
for (const key in this.properties) {
|
|
39
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
40
|
+
if (this.properties.hasOwnProperty(key)) {
|
|
41
|
+
const val = this.properties[key];
|
|
42
|
+
if (val) {
|
|
43
|
+
if (first) {
|
|
44
|
+
first = false;
|
|
45
|
+
} else {
|
|
46
|
+
cmdStr += ',';
|
|
47
|
+
}
|
|
48
|
+
cmdStr += `${key}=${escapeProperty(val)}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
cmdStr += `${CMD_STRING}${escapeData(this.message)}${this.options.EOL}`;
|
|
54
|
+
return cmdStr;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
toCommandProperties: coreUtils.toCommandProperties,
|
|
60
|
+
Command,
|
|
61
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reporters/github",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "A github actions reporter for `node:test`",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"keywords": [
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"stack-utils": "^2.0.6"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"./index.js"
|
|
18
|
+
"./index.js",
|
|
19
|
+
"./gh_core.js"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
22
|
"test": "node --test-reporter=../gh/index.js --test"
|