Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actions/toolkit#127: getInput supports variables with multiple spaces #128

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/core/__tests__/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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}`])
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down