From 86903dfeb96d87b279e2c32e4993d1326375130b Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:50:05 +0900 Subject: [PATCH] fix: set error type to any --- dist/index.js | 48 +++++++++++++++++++++++++++++++++++++++--------- src/main.ts | 2 +- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index e1114d6..7d03bf4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -217,7 +217,7 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const inputs = inputHelper.getInputs(); - core.debug(`Inputs: ${util_1.inspect(inputs)}`); + core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`); inputHelper.validateInputs(inputs); // Fetch the readme content const readmeContent = yield fs.promises.readFile(inputs.readmeFilepath, { @@ -236,7 +236,7 @@ function run() { core.info('Request successful'); } catch (error) { - core.debug(util_1.inspect(error)); + core.debug((0, util_1.inspect)(error)); core.setFailed(error.message); } }); @@ -379,7 +379,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; +exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; const command_1 = __nccwpck_require__(351); const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(278); @@ -557,19 +557,30 @@ exports.debug = debug; /** * Adds an error issue * @param message error issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); +function error(message, properties = {}) { + command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.error = error; /** - * Adds an warning issue + * Adds a warning issue * @param message warning issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); +function warning(message, properties = {}) { + command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.warning = warning; +/** + * Adds a notice issue + * @param message notice issue message. Errors will be converted to string via toString() + * @param properties optional properties to add to the annotation. + */ +function notice(message, properties = {}) { + command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); +} +exports.notice = notice; /** * Writes info to log with console.log. * @param message info message @@ -703,7 +714,7 @@ exports.issueCommand = issueCommand; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.toCommandValue = void 0; +exports.toCommandProperties = exports.toCommandValue = void 0; /** * Sanitizes an input into a string so it can be passed into issueCommand safely * @param input input to sanitize into a string @@ -718,6 +729,25 @@ function toCommandValue(input) { return JSON.stringify(input); } exports.toCommandValue = toCommandValue; +/** + * + * @param annotationProperties + * @returns The command properties to send with the actual annotation command + * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646 + */ +function toCommandProperties(annotationProperties) { + if (!Object.keys(annotationProperties).length) { + return {}; + } + return { + title: annotationProperties.title, + line: annotationProperties.startLine, + endLine: annotationProperties.endLine, + col: annotationProperties.startColumn, + endColumn: annotationProperties.endColumn + }; +} +exports.toCommandProperties = toCommandProperties; //# sourceMappingURL=utils.js.map /***/ }), diff --git a/src/main.ts b/src/main.ts index a21ebf6..fee7899 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,7 @@ async function run(): Promise { readmeContent ) core.info('Request successful') - } catch (error) { + } catch (error: any) { core.debug(inspect(error)) core.setFailed(error.message) }