From a6e72497764b1cf53192eb720f551d7f0db3a4b4 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Mon, 9 Sep 2019 11:46:17 -0400 Subject: [PATCH] Update to use :: instead of ## (#110) * Update to use :: instead of ## * Missed test --- packages/core/__tests__/lib.test.ts | 38 ++++++++++++++--------------- packages/core/package-lock.json | 2 +- packages/core/src/command.ts | 8 +++--- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index dc34213f..9c9b4970 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -33,29 +33,29 @@ describe('@actions/core', () => { it('exportVariable produces the correct command and sets the env', () => { core.exportVariable('my var', 'var val') - assertWriteCalls([`##[set-env name=my var;]var val${os.EOL}`]) + assertWriteCalls([`::set-env name=my var,::var val${os.EOL}`]) }) it('exportVariable escapes variable names', () => { core.exportVariable('special char var \r\n];', 'special val') expect(process.env['special char var \r\n];']).toBe('special val') assertWriteCalls([ - `##[set-env 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', () => { core.exportVariable('my var2', 'var val\r\n') expect(process.env['my var2']).toBe('var val\r\n') - assertWriteCalls([`##[set-env 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', () => { // core.exportSecret('my secret', 'secret val') // expect(process.env['my secret']).toBe('secret val') // assertWriteCalls([ - // `##[set-env name=my secret;]secret val${os.EOL}`, - // `##[set-secret]secret val${os.EOL}` + // `::set-env name=my secret,::secret val${os.EOL}`, + // `::set-secret]secret val${os.EOL}` // ]) // }) @@ -63,10 +63,10 @@ describe('@actions/core', () => { // core.exportSecret('special char secret \r\n];', 'special secret val') // expect(process.env['special char secret \r\n];']).toBe('special secret val') // assertWriteCalls([ - // `##[set-env 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 // }`, - // `##[set-secret]special secret val${os.EOL}` + // `::set-secret]special secret val${os.EOL}` // ]) // }) @@ -74,8 +74,8 @@ describe('@actions/core', () => { // core.exportSecret('my secret2', 'secret val\r\n') // expect(process.env['my secret2']).toBe('secret val\r\n') // assertWriteCalls([ - // `##[set-env name=my secret2;]secret val%0D%0A${os.EOL}`, - // `##[set-secret]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}` // ]) // }) @@ -84,7 +84,7 @@ describe('@actions/core', () => { expect(process.env['PATH']).toBe( `myPath${path.delimiter}path1${path.delimiter}path2` ) - assertWriteCalls([`##[add-path]myPath${os.EOL}`]) + assertWriteCalls([`::add-path::myPath${os.EOL}`]) }) it('getInput gets non-required input', () => { @@ -115,7 +115,7 @@ describe('@actions/core', () => { it('setOutput produces the correct command', () => { 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}`]) }) it('setNeutral sets the correct exit code', () => { @@ -126,33 +126,33 @@ describe('@actions/core', () => { it('setFailure sets the correct exit code and failure message', () => { core.setFailed('Failure message') expect(process.exitCode).toBe(core.ExitCode.Failure) - assertWriteCalls([`##[error]Failure message${os.EOL}`]) + assertWriteCalls([`::error::Failure message${os.EOL}`]) }) it('setFailure escapes the failure message', () => { core.setFailed('Failure \r\n\nmessage\r') expect(process.exitCode).toBe(core.ExitCode.Failure) - assertWriteCalls([`##[error]Failure %0D%0A%0Amessage%0D${os.EOL}`]) + assertWriteCalls([`::error::Failure %0D%0A%0Amessage%0D${os.EOL}`]) }) it('error sets the correct error message', () => { core.error('Error message') - assertWriteCalls([`##[error]Error message${os.EOL}`]) + assertWriteCalls([`::error::Error message${os.EOL}`]) }) it('error escapes the error message', () => { core.error('Error message\r\n\n') - assertWriteCalls([`##[error]Error message%0D%0A%0A${os.EOL}`]) + assertWriteCalls([`::error::Error message%0D%0A%0A${os.EOL}`]) }) it('warning sets the correct message', () => { core.warning('Warning') - assertWriteCalls([`##[warning]Warning${os.EOL}`]) + assertWriteCalls([`::warning::Warning${os.EOL}`]) }) it('warning escapes the message', () => { core.warning('\r\nwarning\n') - assertWriteCalls([`##[warning]%0D%0Awarning%0A${os.EOL}`]) + assertWriteCalls([`::warning::%0D%0Awarning%0A${os.EOL}`]) }) it('startGroup starts a new group', () => { @@ -180,12 +180,12 @@ describe('@actions/core', () => { it('debug sets the correct message', () => { core.debug('Debug') - assertWriteCalls([`##[debug]Debug${os.EOL}`]) + assertWriteCalls([`::debug::Debug${os.EOL}`]) }) it('debug escapes the message', () => { core.debug('\r\ndebug\n') - assertWriteCalls([`##[debug]%0D%0Adebug%0A${os.EOL}`]) + assertWriteCalls([`::debug::%0D%0Adebug%0A${os.EOL}`]) }) }) diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json index 6aee4fab..601a131a 100644 --- a/packages/core/package-lock.json +++ b/packages/core/package-lock.json @@ -1,6 +1,6 @@ { "name": "@actions/core", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/core/src/command.ts b/packages/core/src/command.ts index 4e6e9b41..0773a724 100644 --- a/packages/core/src/command.ts +++ b/packages/core/src/command.ts @@ -29,7 +29,7 @@ export function issue(name: string, message: string = ''): void { issueCommand(name, {}, message) } -const CMD_PREFIX = '##[' +const CMD_STRING = '::' class Command { private readonly command: string @@ -47,7 +47,7 @@ class Command { } toString(): string { - let cmdStr = CMD_PREFIX + this.command + let cmdStr = CMD_STRING + this.command if (this.properties && Object.keys(this.properties).length > 0) { cmdStr += ' ' @@ -57,13 +57,13 @@ class Command { if (val) { // safely append the val - avoid blowing up when attempting to // call .replace() if message is not a string for some reason - cmdStr += `${key}=${escape(`${val || ''}`)};` + cmdStr += `${key}=${escape(`${val || ''}`)},` } } } } - cmdStr += ']' + cmdStr += CMD_STRING // safely append the message - avoid blowing up when attempting to // call .replace() if message is not a string for some reason