diff --git a/__tests__/core.test.ts b/__tests__/core.test.ts index fd7fd57..b54752e 100644 --- a/__tests__/core.test.ts +++ b/__tests__/core.test.ts @@ -132,10 +132,12 @@ describe('@actions/core', () => { it('exportVariable does not allow delimiter as value', () => { const command = 'ENV' createFileCommandFile(command) - + expect(() => { core.exportVariable('my var', `good stuff ${DELIMITER} bad stuff`) - }).toThrow(`Unexpected input: value should not contain the delimiter "${DELIMITER}"`) + }).toThrow( + `Unexpected input: value should not contain the delimiter "${DELIMITER}"` + ) const filePath = path.join(__dirname, `test/${command}`) fs.unlinkSync(filePath) @@ -144,11 +146,13 @@ describe('@actions/core', () => { it('exportVariable does not allow delimiter as name', () => { const command = 'ENV' createFileCommandFile(command) - + expect(() => { core.exportVariable(`good stuff ${DELIMITER} bad stuff`, 'test') - }).toThrow(`Unexpected input: name should not contain the delimiter "${DELIMITER}"`) - + }).toThrow( + `Unexpected input: name should not contain the delimiter "${DELIMITER}"` + ) + const filePath = path.join(__dirname, `test/${command}`) fs.unlinkSync(filePath) }) diff --git a/src/core.ts b/src/core.ts index 85bdcb5..f123aaa 100644 --- a/src/core.ts +++ b/src/core.ts @@ -4,7 +4,7 @@ import {toCommandProperties, toCommandValue} from './utils' import * as os from 'os' import * as path from 'path' -import { v4 as uuidv4 } from 'uuid' +import {v4 as uuidv4} from 'uuid' import {OidcClient} from './oidc-utils' @@ -89,13 +89,17 @@ export function exportVariable(name: string, val: any): void { if (filePath) { const delimiter = `ghadelimiter_${uuidv4()}` - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. + // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`) + throw new Error( + `Unexpected input: name should not contain the delimiter "${delimiter}"` + ) } if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`) + throw new Error( + `Unexpected input: value should not contain the delimiter "${delimiter}"` + ) } const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`