Skip to content

Commit

Permalink
Throw error if semverLevel not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Jul 12, 2023
1 parent 1a7bbcf commit de52f1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ const core = require('@actions/core');
const _ = require('underscore');
const versionUpdater = require('../../../libs/versionUpdater');

let semverLevel = core.getInput('SEMVER_LEVEL', {require: true});
const semverLevel = core.getInput('SEMVER_LEVEL', {require: true});
if (!semverLevel || !_.contains(versionUpdater.SEMANTIC_VERSION_LEVELS, semverLevel)) {
semverLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.PATCH;
console.warn(`Invalid input for 'SEMVER_LEVEL': ${semverLevel}`, `Defaulting to: ${semverLevel}`);
core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`);
}

const {version: currentVersion} = JSON.parse(readFileSync('./package.json'));
Expand Down
5 changes: 2 additions & 3 deletions .github/actions/javascript/getPreviousVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ const core = __nccwpck_require__(186);
const _ = __nccwpck_require__(571);
const versionUpdater = __nccwpck_require__(7);

let semverLevel = core.getInput('SEMVER_LEVEL', {require: true});
const semverLevel = core.getInput('SEMVER_LEVEL', {require: true});
if (!semverLevel || !_.contains(versionUpdater.SEMANTIC_VERSION_LEVELS, semverLevel)) {
semverLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.PATCH;
console.warn(`Invalid input for 'SEMVER_LEVEL': ${semverLevel}`, `Defaulting to: ${semverLevel}`);
core.setFailed(`'Error: Invalid input for 'SEMVER_LEVEL': ${semverLevel}`);
}

const {version: currentVersion} = JSON.parse(readFileSync('./package.json'));
Expand Down

0 comments on commit de52f1f

Please sign in to comment.