Make not specifying a required input a user error

This commit is contained in:
Henry Mercer 2023-07-28 18:18:27 +01:00
parent 81ae676e79
commit 5691205077
3 changed files with 11 additions and 3 deletions

6
lib/actions-util.js generated
View file

@ -39,7 +39,11 @@ const pkg = require("../package.json");
* This allows us to get stronger type checking of required/optional inputs.
*/
const getRequiredInput = function (name) {
return core.getInput(name, { required: true });
const value = core.getInput(name);
if (!value) {
throw new util_1.UserError(`Input required and not supplied: ${name}`);
}
return value;
};
exports.getRequiredInput = getRequiredInput;
/**

File diff suppressed because one or more lines are too long

View file

@ -24,7 +24,11 @@ const pkg = require("../package.json") as JSONSchemaForNPMPackageJsonFiles;
* This allows us to get stronger type checking of required/optional inputs.
*/
export const getRequiredInput = function (name: string): string {
return core.getInput(name, { required: true });
const value = core.getInput(name);
if (!value) {
throw new UserError(`Input required and not supplied: ${name}`);
}
return value;
};
/**