1
0
Fork 0

set-env instead of set-variable

pull/4/head
Danny McCormick 2019-05-21 14:40:57 -04:00
parent ea0dd28ea7
commit b25c8772ed
2 changed files with 7 additions and 7 deletions

View File

@ -29,28 +29,28 @@ describe('@actions/core', () => {
it('exportVariable produces the correct command and sets the env', () => { it('exportVariable produces the correct command and sets the env', () => {
core.exportVariable('my var', 'var val') core.exportVariable('my var', 'var val')
assertWriteCalls([`##[set-variable name=my var;]var val${os.EOL}`]) assertWriteCalls([`##[set-env name=my var;]var val${os.EOL}`])
}) })
it('exportVariable escapes variable names', () => { it('exportVariable escapes variable names', () => {
core.exportVariable('special char var \r\n];', 'special val') core.exportVariable('special char var \r\n];', 'special val')
expect(process.env['special char var \r\n];']).toBe('special val') expect(process.env['special char var \r\n];']).toBe('special val')
assertWriteCalls([ assertWriteCalls([
`##[set-variable name=special char var %0D%0A%5D%3B;]special val${os.EOL}` `##[set-env name=special char var %0D%0A%5D%3B;]special val${os.EOL}`
]) ])
}) })
it('exportVariable escapes variable values', () => { it('exportVariable escapes variable values', () => {
core.exportVariable('my var2', 'var val\r\n') core.exportVariable('my var2', 'var val\r\n')
expect(process.env['my var2']).toBe('var val\r\n') expect(process.env['my var2']).toBe('var val\r\n')
assertWriteCalls([`##[set-variable name=my var2;]var val%0D%0A${os.EOL}`]) assertWriteCalls([`##[set-env name=my var2;]var val%0D%0A${os.EOL}`])
}) })
it('exportSecret produces the correct commands and sets the env', () => { it('exportSecret produces the correct commands and sets the env', () => {
core.exportSecret('my secret', 'secret val') core.exportSecret('my secret', 'secret val')
expect(process.env['my secret']).toBe('secret val') expect(process.env['my secret']).toBe('secret val')
assertWriteCalls([ assertWriteCalls([
`##[set-variable name=my secret;]secret val${os.EOL}`, `##[set-env name=my secret;]secret val${os.EOL}`,
`##[set-secret]secret val${os.EOL}` `##[set-secret]secret val${os.EOL}`
]) ])
}) })
@ -59,7 +59,7 @@ describe('@actions/core', () => {
core.exportSecret('special char secret \r\n];', 'special secret val') core.exportSecret('special char secret \r\n];', 'special secret val')
expect(process.env['special char secret \r\n];']).toBe('special secret val') expect(process.env['special char secret \r\n];']).toBe('special secret val')
assertWriteCalls([ assertWriteCalls([
`##[set-variable name=special char secret %0D%0A%5D%3B;]special secret val${ `##[set-env name=special char secret %0D%0A%5D%3B;]special secret val${
os.EOL os.EOL
}`, }`,
`##[set-secret]special secret val${os.EOL}` `##[set-secret]special secret val${os.EOL}`
@ -70,7 +70,7 @@ describe('@actions/core', () => {
core.exportSecret('my secret2', 'secret val\r\n') core.exportSecret('my secret2', 'secret val\r\n')
expect(process.env['my secret2']).toBe('secret val\r\n') expect(process.env['my secret2']).toBe('secret val\r\n')
assertWriteCalls([ assertWriteCalls([
`##[set-variable name=my secret2;]secret val%0D%0A${os.EOL}`, `##[set-env name=my secret2;]secret val%0D%0A${os.EOL}`,
`##[set-secret]secret val%0D%0A${os.EOL}` `##[set-secret]secret val%0D%0A${os.EOL}`
]) ])
}) })

View File

@ -20,7 +20,7 @@ export interface InputOptions {
*/ */
export function exportVariable(name: string, val: string) { export function exportVariable(name: string, val: string) {
process.env[name] = val process.env[name] = val
intm.issueCommand('set-variable', {name}, val) intm.issueCommand('set-env', {name}, val)
} }
/** /**