Skip to content

Commit e58193e

Browse files
committed
Load owner name from problem matcher file
1 parent 5cdcb6e commit e58193e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"promisify"
4+
]
5+
}

src/main.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1+
import { readFile } from "fs";
12
import { join } from "path";
3+
import { promisify } from "util";
24

35
import { getInput, setFailed } from "@actions/core";
46
import { issueCommand } from "@actions/core/lib/command"
57

6-
export function run() {
8+
import { ProblemMatcher } from "github-actions-problem-matcher-typings";
9+
10+
const readFileAsync = promisify(readFile);
11+
12+
export async function run() {
713
try {
814
const action = getInput("action");
915

16+
const matcherFile = join(__dirname, "..", ".github", "problem-matcher.json");
17+
1018
switch (action) {
1119
case "add":
1220
issueCommand(
1321
"add-matcher",
1422
{},
15-
join(__dirname, "..", ".github", "problem-matcher.json"),
23+
matcherFile,
1624
);
1725
break;
1826

1927
case "remove":
28+
const fileContents = await readFileAsync(matcherFile, { encoding: "utf8" });
29+
const problemMatcher: ProblemMatcher = JSON.parse(fileContents);
30+
2031
issueCommand(
2132
"remove-matcher",
2233
{
23-
owner: "dotnet-format",
34+
owner: problemMatcher.owner,
2435
},
2536
"",
2637
);

0 commit comments

Comments
 (0)