[feat] Add fromPath to matcher template

This commit is contained in:
olemorud
2023-03-14 17:38:18 +01:00
parent b651f721c4
commit 0de4817981
5 changed files with 19 additions and 22 deletions

View File

@@ -23,7 +23,7 @@ jobs:
- name: Apply problem matcher - name: Apply problem matcher
uses: ./ uses: ./
with: with:
build-directory: "" build-directory: build/
- name: Test problem matcher - name: Test problem matcher
run: | run: |

View File

@@ -4,12 +4,13 @@
"owner": "gcc-problem-matcher", "owner": "gcc-problem-matcher",
"pattern": [ "pattern": [
{ {
"regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", "regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1, "fromPath": 1,
"line": 2, "file": 2,
"column": 3, "line": 3,
"severity": 4, "column": 4,
"message": 5 "severity": 5,
"message": 6
} }
] ]
} }

11
dist/index.js vendored
View File

@@ -2862,18 +2862,13 @@ const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate";
const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json"; const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json";
// rootdir :: string // rootdir :: string
const rootdir = () => const rootdir = core.getInput('build-directory', {required: false});
core.getInput('build-directory', {required: false});
// parse :: IO() => IO() => Error | null // parse :: string => string => Error | null
const parse = (templatePath) => (matcherPath) => { const parse = (templatePath) => (matcherPath) => {
const r = rootdir();
console.log(r);
const content = fs.readFileSync(templatePath, 'utf-8'); const content = fs.readFileSync(templatePath, 'utf-8');
const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir())); const parsed = content.replace(variable("BASE"), escapeRegExp(rootdir));
fs.writeFileSync(matcherPath, parsed); fs.writeFileSync(matcherPath, parsed);

View File

@@ -4,12 +4,13 @@
"owner": "gcc-problem-matcher", "owner": "gcc-problem-matcher",
"pattern": [ "pattern": [
{ {
"regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", "regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1, "fromPath": 1,
"line": 2, "file": 2,
"column": 3, "line": 3,
"severity": 4, "column": 4,
"message": 5 "severity": 5,
"message": 6
} }
] ]
} }

View File

@@ -21,7 +21,7 @@ const matcherPath = path.join(__dirname, "gcc_matcher.json");
// rootdir :: string // rootdir :: string
const rootdir = core.getInput('build-directory', {required: false}); const rootdir = core.getInput('build-directory', {required: false});
// parse :: IO() => IO() => Error | null // parse :: string => string => Error | null
const parse = (templatePath) => (matcherPath) => { const parse = (templatePath) => (matcherPath) => {
const content = fs.readFileSync(templatePath, 'utf-8'); const content = fs.readFileSync(templatePath, 'utf-8');