Skip to content

Commit 0de4817

Browse files
committed
[feat] Add fromPath to matcher template
1 parent b651f72 commit 0de4817

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Apply problem matcher
2424
uses: ./
2525
with:
26-
build-directory: ""
26+
build-directory: build/
2727

2828
- name: Test problem matcher
2929
run: |

dist/gcc_matcher.jsontemplate

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"owner": "gcc-problem-matcher",
55
"pattern": [
66
{
7-
"regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8-
"file": 1,
9-
"line": 2,
10-
"column": 3,
11-
"severity": 4,
12-
"message": 5
7+
"regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8+
"fromPath": 1,
9+
"file": 2,
10+
"line": 3,
11+
"column": 4,
12+
"severity": 5,
13+
"message": 6
1314
}
1415
]
1516
}

dist/index.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -2862,18 +2862,13 @@ const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate";
28622862
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
28632863

28642864
// rootdir :: string
2865-
const rootdir = () =>
2866-
core.getInput('build-directory', {required: false});
2865+
const rootdir = core.getInput('build-directory', {required: false});
28672866

2868-
// parse :: IO() => IO() => Error | null
2867+
// parse :: string => string => Error | null
28692868
const parse = (templatePath) => (matcherPath) => {
2870-
const r = rootdir();
2871-
2872-
console.log(r);
2873-
28742869
const content = fs.readFileSync(templatePath, 'utf-8');
28752870

2876-
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir()));
2871+
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
28772872

28782873
fs.writeFileSync(matcherPath, parsed);
28792874

src/gcc_matcher.jsontemplate

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"owner": "gcc-problem-matcher",
55
"pattern": [
66
{
7-
"regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8-
"file": 1,
9-
"line": 2,
10-
"column": 3,
11-
"severity": 4,
12-
"message": 5
7+
"regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
8+
"fromPath": 1,
9+
"file": 2,
10+
"line": 3,
11+
"column": 4,
12+
"severity": 5,
13+
"message": 6
1314
}
1415
]
1516
}

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const matcherPath = path.join(__dirname, "gcc_matcher.json");
2121
// rootdir :: string
2222
const rootdir = core.getInput('build-directory', {required: false});
2323

24-
// parse :: IO() => IO() => Error | null
24+
// parse :: string => string => Error | null
2525
const parse = (templatePath) => (matcherPath) => {
2626
const content = fs.readFileSync(templatePath, 'utf-8');
2727

0 commit comments

Comments
 (0)