From dda46c2691e0221549b7af37a39d99753cf9d8c6 Mon Sep 17 00:00:00 2001 From: manusa Date: Wed, 11 Sep 2019 10:12:10 +0200 Subject: [PATCH] actions/toolkit#127: getInput supports variables with multiple spaces --- packages/core/__tests__/lib.test.ts | 7 ++++++- packages/core/src/core.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index 23c3aafb6d..605cf1143a 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -16,7 +16,8 @@ const testEnvVars = { // Set inputs INPUT_MY_INPUT: 'val', INPUT_MISSING: '', - 'INPUT_SPECIAL_CHARS_\'\t"\\': '\'\t"\\ response ' + 'INPUT_SPECIAL_CHARS_\'\t"\\': '\'\t"\\ response ', + 'INPUT_MULTIPLE_SPACES_VARIABLE': 'I have multiple spaces' } describe('@actions/core', () => { @@ -113,6 +114,10 @@ describe('@actions/core', () => { expect(core.getInput('special chars_\'\t"\\')).toBe('\'\t"\\ response') }) + it('getInput handles multiple spaces', () => { + expect(core.getInput('multiple spaces variable')).toBe('I have multiple spaces') + }) + it('setOutput produces the correct command', () => { core.setOutput('some output', 'some value') assertWriteCalls([`::set-output name=some output,::some value${os.EOL}`]) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index f7f174304a..74e8aacf5f 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -72,7 +72,7 @@ export function addPath(inputPath: string): void { */ export function getInput(name: string, options?: InputOptions): string { const val: string = - process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '' + process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '' if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name}`) }