From 5da5e6bd61e4c715afd71529e16982ea5924fc7c Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Mon, 20 Nov 2023 19:54:57 +1100 Subject: [PATCH] fix: handle input validation better --- badges/coverage.svg | 2 +- dist/index.js | 3 ++- src/io/parseInput.ts | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index 517f8f3..39e5aa7 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 32.52%Coverage32.52% \ No newline at end of file +Coverage: 33.06%Coverage33.06% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index e19294f..b5b788c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29864,6 +29864,7 @@ exports.parseInput = void 0; const core_1 = __nccwpck_require__(2186); const debugJson_1 = __nccwpck_require__(3562); const github_1 = __nccwpck_require__(5438); +const USE_SEMANTIC_COMMITS = 'INPUT_USE-SEMANTIC-COMMITS'; const getAuthor = () => { const name = (0, core_1.getInput)('author-name'); const email = (0, core_1.getInput)('author-email'); @@ -29873,7 +29874,7 @@ const getAuthor = () => { return { name, email }; }; const parseInput = () => { - const hasSemanticCommitConfig = 'INPUT_USE-SEMANTIC-COMMITS' in process.env; + const hasSemanticCommitConfig = process.env[USE_SEMANTIC_COMMITS] != null && process.env[USE_SEMANTIC_COMMITS] !== ''; if (hasSemanticCommitConfig) { (0, core_1.warning)('The use-semantic-commits option was renamed to use-conventional-commits and will be removed at some point'); } diff --git a/src/io/parseInput.ts b/src/io/parseInput.ts index 1d7ff10..230791c 100644 --- a/src/io/parseInput.ts +++ b/src/io/parseInput.ts @@ -2,6 +2,8 @@ import { getBooleanInput, getInput, warning } from '@actions/core'; import { debugJson } from './debugJson'; import { getOctokit } from '@actions/github'; +const USE_SEMANTIC_COMMITS = 'INPUT_USE-SEMANTIC-COMMITS'; + export interface ActionInput { author?: { name: string; @@ -24,7 +26,7 @@ const getAuthor = (): undefined | { name: string; email: string } => { }; export const parseInput = (): ActionInput => { - const hasSemanticCommitConfig = 'INPUT_USE-SEMANTIC-COMMITS' in process.env; + const hasSemanticCommitConfig = process.env[USE_SEMANTIC_COMMITS] != null && process.env[USE_SEMANTIC_COMMITS] !== ''; if (hasSemanticCommitConfig) { warning( 'The use-semantic-commits option was renamed to use-conventional-commits and will be removed at some point',