mirror of https://github.com/actions/toolkit
actions/toolkit#127: getInput supports variables with multiple spaces (#129)
* actions/toolkit#127: getInput supports variables with multiple spaces * actions/toolkit#127: PR comment, update changelogpull/134/head
parent
b297969f56
commit
6fcaac5046
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
### Unreleased
|
### Unreleased
|
||||||
|
|
||||||
|
- Add support for action input variables with multiple spaces [#127](https://github.com/actions/toolkit/issues/127)
|
||||||
- Switched ## commands to :: commands (should have no noticeable impact) [#110)(https://github.com/actions/toolkit/pull/110)
|
- Switched ## commands to :: commands (should have no noticeable impact) [#110)(https://github.com/actions/toolkit/pull/110)
|
||||||
|
|
||||||
### 1.1.0
|
### 1.1.0
|
||||||
|
|
|
@ -16,7 +16,8 @@ const testEnvVars = {
|
||||||
// Set inputs
|
// Set inputs
|
||||||
INPUT_MY_INPUT: 'val',
|
INPUT_MY_INPUT: 'val',
|
||||||
INPUT_MISSING: '',
|
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', () => {
|
describe('@actions/core', () => {
|
||||||
|
@ -113,6 +114,12 @@ describe('@actions/core', () => {
|
||||||
expect(core.getInput('special chars_\'\t"\\')).toBe('\'\t"\\ response')
|
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', () => {
|
it('setOutput produces the correct command', () => {
|
||||||
core.setOutput('some output', 'some value')
|
core.setOutput('some output', 'some value')
|
||||||
assertWriteCalls([`::set-output name=some output,::some value${os.EOL}`])
|
assertWriteCalls([`::set-output name=some output,::some value${os.EOL}`])
|
||||||
|
|
|
@ -72,7 +72,7 @@ export function addPath(inputPath: string): void {
|
||||||
*/
|
*/
|
||||||
export function getInput(name: string, options?: InputOptions): string {
|
export function getInput(name: string, options?: InputOptions): string {
|
||||||
const val: string =
|
const val: string =
|
||||||
process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''
|
process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''
|
||||||
if (options && options.required && !val) {
|
if (options && options.required && !val) {
|
||||||
throw new Error(`Input required and not supplied: ${name}`)
|
throw new Error(`Input required and not supplied: ${name}`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue