From 0de4817981867f31b939550d2b72f824b0ccefb7 Mon Sep 17 00:00:00 2001 From: olemorud Date: Tue, 14 Mar 2023 17:38:18 +0100 Subject: [PATCH] [feat] Add fromPath to matcher template --- .github/workflows/CI.yml | 2 +- dist/gcc_matcher.jsontemplate | 13 +++++++------ dist/index.js | 11 +++-------- src/gcc_matcher.jsontemplate | 13 +++++++------ src/index.js | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 47bf6b3..10d2580 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,7 @@ jobs: - name: Apply problem matcher uses: ./ with: - build-directory: "" + build-directory: build/ - name: Test problem matcher run: | diff --git a/dist/gcc_matcher.jsontemplate b/dist/gcc_matcher.jsontemplate index d157a38..9019aee 100644 --- a/dist/gcc_matcher.jsontemplate +++ b/dist/gcc_matcher.jsontemplate @@ -4,12 +4,13 @@ "owner": "gcc-problem-matcher", "pattern": [ { - "regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "message": 5 + "regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "fromPath": 1, + "file": 2, + "line": 3, + "column": 4, + "severity": 5, + "message": 6 } ] } diff --git a/dist/index.js b/dist/index.js index 4efab8a..ab975fa 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2862,18 +2862,13 @@ const templatePath = __nccwpck_require__.ab + "gcc_matcher.jsontemplate"; const matcherPath = __nccwpck_require__.ab + "gcc_matcher.json"; // 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 r = rootdir(); - - console.log(r); - 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); diff --git a/src/gcc_matcher.jsontemplate b/src/gcc_matcher.jsontemplate index d157a38..9019aee 100644 --- a/src/gcc_matcher.jsontemplate +++ b/src/gcc_matcher.jsontemplate @@ -4,12 +4,13 @@ "owner": "gcc-problem-matcher", "pattern": [ { - "regexp": "^.*?${{ BASE }}\/?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "message": 5 + "regexp": "^(${{ BASE }})(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "fromPath": 1, + "file": 2, + "line": 3, + "column": 4, + "severity": 5, + "message": 6 } ] } diff --git a/src/index.js b/src/index.js index 0a60ade..b58216e 100644 --- a/src/index.js +++ b/src/index.js @@ -21,7 +21,7 @@ const matcherPath = path.join(__dirname, "gcc_matcher.json"); // rootdir :: string const rootdir = core.getInput('build-directory', {required: false}); -// parse :: IO() => IO() => Error | null +// parse :: string => string => Error | null const parse = (templatePath) => (matcherPath) => { const content = fs.readFileSync(templatePath, 'utf-8');