diff --git a/dist/index.js b/dist/index.js index 649104e..9bd545e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -20211,11 +20211,12 @@ var require_file_command = __commonJS({ return result; }; Object.defineProperty(exports, '__esModule', { value: true }); - exports.issueCommand = void 0; + exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; var fs = __importStar(require('fs')); var os = __importStar(require('os')); + var uuid_1 = require_dist(); var utils_1 = require_utils(); - function issueCommand(command, message) { + function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -20227,7 +20228,19 @@ var require_file_command = __commonJS({ encoding: 'utf8', }); } - exports.issueCommand = issueCommand; + exports.issueFileCommand = issueFileCommand; + function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; + } + exports.prepareKeyValueMessage = prepareKeyValueMessage; }, }); @@ -21686,7 +21699,6 @@ var require_core2 = __commonJS({ var utils_1 = require_utils(); var os = __importStar(require('os')); var path = __importStar(require('path')); - var uuid_1 = require_dist(); var oidc_utils_1 = require_oidc_utils(); var ExitCode; (function (ExitCode2) { @@ -21698,18 +21710,9 @@ var require_core2 = __commonJS({ process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - if (name.includes(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}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; function setSecret2(secret) { @@ -21719,7 +21722,7 @@ var require_core2 = __commonJS({ function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); } @@ -21741,7 +21744,10 @@ var require_core2 = __commonJS({ const inputs = getInput2(name, options) .split('\n') .filter((x) => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map((input) => input.trim()); } exports.getMultilineInput = getMultilineInput; function getBooleanInput(name, options) { @@ -21755,8 +21761,12 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports.getBooleanInput = getBooleanInput; function setOutput2(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput2; function setCommandEcho(enabled) { @@ -21826,7 +21836,11 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports.group = group; function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; function getState(name) { diff --git a/package-lock.json b/package-lock.json index 3691cb5..cb3d7b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@typescript-eslint/eslint-plugin": "5.23.0", "@typescript-eslint/parser": "5.23.0", "ajv-keywords": "5.1.0", - "bufferutil": "4.0.6", + "bufferutil": "4.0.7", "esbuild": "0.14.44", "eslint": "8.23.0", "eslint-config-prettier": "8.5.0", @@ -2279,9 +2279,9 @@ "dev": true }, "node_modules/bufferutil": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.6.tgz", - "integrity": "sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -10802,9 +10802,9 @@ "dev": true }, "bufferutil": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.6.tgz", - "integrity": "sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", "dev": true, "requires": { "node-gyp-build": "^4.3.0" diff --git a/package.json b/package.json index e5884b1..e96b070 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "@typescript-eslint/eslint-plugin": "5.23.0", "@typescript-eslint/parser": "5.23.0", "ajv-keywords": "5.1.0", - "bufferutil": "4.0.6", + "bufferutil": "4.0.7", "esbuild": "0.14.44", "eslint": "8.23.0", "eslint-config-prettier": "8.5.0",