From fd35ce3d2c7f7c824b9c1fd675a434660d38972b Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 15 Aug 2020 14:09:05 -0400 Subject: [PATCH] feat: allow folder of problem matcher registration Allows registering of new problem matchers by adding them to folder --- dist/index.js | 11 +++++++---- {.github => matchers}/eslint-compact.json | 0 {.github => matchers}/eslint-stylish.json | 0 {.github => matchers}/tsc.json | 0 src/main.ts | 15 +++++++-------- 5 files changed, 14 insertions(+), 12 deletions(-) rename {.github => matchers}/eslint-compact.json (100%) rename {.github => matchers}/eslint-stylish.json (100%) rename {.github => matchers}/tsc.json (100%) diff --git a/dist/index.js b/dist/index.js index 481183ea6..a6362b3d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4632,6 +4632,7 @@ const installer = __importStar(__webpack_require__(749)); const auth = __importStar(__webpack_require__(202)); const path = __importStar(__webpack_require__(622)); const url_1 = __webpack_require__(835); +const fs = __importStar(__webpack_require__(747)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -4655,10 +4656,12 @@ function run() { if (registryUrl) { auth.configAuthentication(registryUrl, alwaysAuth); } - const matchersPath = path.join(__dirname, '..', '.github'); - console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); - console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`); - console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`); + // Iterate and register all problem matchers + const matchersPath = path.join(__dirname, '..', 'matchers'); + const matchers = fs.readdirSync(matchersPath); + matchers.forEach((matcher) => { + console.log(`##[add-matcher]${path.join(matchersPath, matcher)}`); + }); } catch (error) { core.setFailed(error.message); diff --git a/.github/eslint-compact.json b/matchers/eslint-compact.json similarity index 100% rename from .github/eslint-compact.json rename to matchers/eslint-compact.json diff --git a/.github/eslint-stylish.json b/matchers/eslint-stylish.json similarity index 100% rename from .github/eslint-stylish.json rename to matchers/eslint-stylish.json diff --git a/.github/tsc.json b/matchers/tsc.json similarity index 100% rename from .github/tsc.json rename to matchers/tsc.json diff --git a/src/main.ts b/src/main.ts index 328db0d26..eec051b78 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ import * as installer from './installer'; import * as auth from './authutil'; import * as path from 'path'; import {URL} from 'url'; +import * as fs from 'fs'; export async function run() { try { @@ -30,14 +31,12 @@ export async function run() { auth.configAuthentication(registryUrl, alwaysAuth); } - const matchersPath = path.join(__dirname, '..', '.github'); - console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); - console.log( - `##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}` - ); - console.log( - `##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}` - ); + // Iterate and register all problem matchers + const matchersPath = path.join(__dirname, '..', 'matchers'); + const matchers = fs.readdirSync(matchersPath); + matchers.forEach(matcher => { + console.log(`##[add-matcher]${path.join(matchersPath, matcher)}`); + }); } catch (error) { core.setFailed(error.message); }