Enabling rustfmt problem matcher on demand

This commit is contained in:
svartalf 2019-10-22 14:35:28 +03:00
parent 333d0cf286
commit d45f23b72c
4 changed files with 21 additions and 14 deletions

View file

@ -2,11 +2,13 @@
"problemMatcher": [ "problemMatcher": [
{ {
"owner": "rustfmt", "owner": "rustfmt",
"pattern": { "pattern": [
"regexp": "^Diff in (\\S+) at line (\\d+):$", {
"file": 1, "regexp": "^Diff in (\\S+) at line (\\d+):$",
"line": 2 "file": 1,
} "line": 2
}
]
} }
] ]
} }

View file

@ -2,11 +2,13 @@
"problemMatcher": [ "problemMatcher": [
{ {
"owner": "rustfmt", "owner": "rustfmt",
"pattern": { "pattern": [
"regexp": "^Diff in (\\S+) at line (\\d+):$", {
"file": 1, "regexp": "^Diff in (\\S+) at line (\\d+):$",
"line": 2 "file": 1,
} "line": 2
}
]
} }
] ]
} }

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -24,11 +24,14 @@ export async function run(actionInput: input.Input): Promise<void> {
} }
async function main(): Promise<void> { async function main(): Promise<void> {
const actionInput = input.get();
const matchersPath = path.join(__dirname, '.matchers'); const matchersPath = path.join(__dirname, '.matchers');
console.log(`::add-matcher::${path.join(matchersPath, 'rust.json')}`); console.log(`::add-matcher::${path.join(matchersPath, 'rust.json')}`);
console.log(`::add-matcher::${path.join(matchersPath, 'rustfmt.json')}`); // Enabling `rustfmt` problem matcher only if `cargo fmt` is called
if (actionInput.command == 'fmt') {
const actionInput = input.get(); console.log(`::add-matcher::${path.join(matchersPath, 'rustfmt.json')}`);
}
try { try {
await run(actionInput); await run(actionInput);