Fix to make utils.readEnv more resilient to user input

This commit is contained in:
Shivam Mathur
2021-07-23 16:19:00 +05:30
parent 7bd9f10bef
commit 4bb4f1812c
3 changed files with 22 additions and 14 deletions

View File

@ -11,13 +11,16 @@ import * as core from '@actions/core';
* @param property
*/
export async function readEnv(property: string): Promise<string> {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
const property_lc: string = property.toLowerCase();
const property_uc: string = property.toUpperCase();
return (
process.env[property] ||
process.env[property_lc] ||
process.env[property_uc] ||
process.env[property_lc.replace('_', '-')] ||
process.env[property_uc.replace('_', '-')] ||
''
);
}
/**