getRequiredEnvParams must be non-empty

This commit is contained in:
Robin Neatherway 2020-06-26 11:44:17 +01:00
parent 17548064f9
commit bb9ed79f3d
6 changed files with 17 additions and 4 deletions

View file

@ -64,3 +64,10 @@ test('getThreadsFlag() throws if the ram input is < 0 or NaN', t => {
t.throws(util.getThreadsFlag);
}
});
test('getRef() throws on the empty string', t => {
for (const input of [""]) {
process.env["GITHUB_REF"] = input;
t.throws(util.getRef);
}
});

View file

@ -37,7 +37,7 @@ export function should_abort(actionName: string, requireInitActionHasRun: boolea
*/
export function getRequiredEnvParam(paramName: string): string {
const value = process.env[paramName];
if (value === undefined) {
if (value === undefined || value.length === 0) {
throw new Error(paramName + ' environment variable must be set');
}
core.debug(paramName + '=' + value);