forked from pascalgn/size-label-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (49 loc) · 1.09 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require("fs");
const process = require("process");
require("dotenv").config();
const tmp = require("tmp");
tmp.setGracefulCleanup();
const index = require("./dist/index");
async function main() {
const eventPayloadPath = await tmpFile(
JSON.stringify({
action: "synchronize",
pull_request: {
number: process.env.PR_NUMBER,
labels: [],
base: {
repo: {
name: process.env.PR_NAME,
owner: {
login: process.env.PR_OWNER
}
}
}
}
})
);
process.env.DEBUG_ACTION = "1";
process.env.GITHUB_EVENT_PATH = eventPayloadPath;
await index.main();
}
function tmpFile(content) {
return new Promise((resolve, reject) => {
tmp.file({ postfix: ".json" }, (err, path) => {
if (err) {
reject(err);
} else {
fs.writeFile(path, content, err => {
if (err) {
reject(err);
} else {
resolve(path);
}
});
}
});
});
}
main().catch(e => {
process.exitCode = 1;
console.error(e);
});