1
0
Fork 0

Add tests, getInput should be case-insensitive and trim output

pull/4/head
Danny McCormick 2019-05-17 10:31:07 -04:00
parent 7c079ef90d
commit 5f31b6acfc
3 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ describe('@actions/core', () => {
});
it('getInput throws on missing required input', () => {
expect(() => core.getInput('missing', {required: true})).toThrow('Failed to find input missing');
expect(() => core.getInput('missing', {required: true})).toThrow('Input required and not supplied: missing');
});
it('getInput doesnt throw on missing non-required input', () => {

View File

@ -9,7 +9,7 @@
"author": "Bryan MacFarlane <bryanmac@microsoft.com>",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"license": "MIT",
"main": "lib/lib.js",
"main": "lib/core.js",
"directories": {
"lib": "lib",
"test": "__tests__"

View File

@ -34,12 +34,12 @@ export function setSecret(name: string, val: string) {
* @returns string
*/
export function getInput(name: string, options?: im.InputOptions): string {
let val:string = process.env['INPUT_' + name];
let val: string = process.env['INPUT_' + name.replace(' ', '_').toUpperCase()] || '';
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val;
return val.trim();
}
//-----------------------------------------------------------------------