@@ -2484,7 +2484,6 @@ const file_command_1 = __nccwpck_require__(717);
24842484const utils_1 = __nccwpck_require__(5278);
24852485const os = __importStar(__nccwpck_require__(2087));
24862486const path = __importStar(__nccwpck_require__(5622));
2487- const uuid_1 = __nccwpck_require__(5840);
24882487const oidc_utils_1 = __nccwpck_require__(8041);
24892488/**
24902489 * The code to exit an action
@@ -2514,20 +2513,9 @@ function exportVariable(name, val) {
25142513 process.env[name] = convertedVal;
25152514 const filePath = process.env['GITHUB_ENV'] || '';
25162515 if (filePath) {
2517- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
2518- // 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.
2519- if (name.includes(delimiter)) {
2520- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
2521- }
2522- if (convertedVal.includes(delimiter)) {
2523- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
2524- }
2525- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
2526- file_command_1.issueCommand('ENV', commandValue);
2527- }
2528- else {
2529- command_1.issueCommand('set-env', { name }, convertedVal);
2516+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
25302517 }
2518+ command_1.issueCommand('set-env', { name }, convertedVal);
25312519}
25322520exports.exportVariable = exportVariable;
25332521/**
@@ -2545,7 +2533,7 @@ exports.setSecret = setSecret;
25452533function addPath(inputPath) {
25462534 const filePath = process.env['GITHUB_PATH'] || '';
25472535 if (filePath) {
2548- file_command_1.issueCommand ('PATH', inputPath);
2536+ file_command_1.issueFileCommand ('PATH', inputPath);
25492537 }
25502538 else {
25512539 command_1.issueCommand('add-path', {}, inputPath);
@@ -2585,7 +2573,10 @@ function getMultilineInput(name, options) {
25852573 const inputs = getInput(name, options)
25862574 .split('\n')
25872575 .filter(x => x !== '');
2588- return inputs;
2576+ if (options && options.trimWhitespace === false) {
2577+ return inputs;
2578+ }
2579+ return inputs.map(input => input.trim());
25892580}
25902581exports.getMultilineInput = getMultilineInput;
25912582/**
@@ -2618,8 +2609,12 @@ exports.getBooleanInput = getBooleanInput;
26182609 */
26192610// eslint-disable-next-line @typescript-eslint/no-explicit-any
26202611function setOutput(name, value) {
2612+ const filePath = process.env['GITHUB_OUTPUT'] || '';
2613+ if (filePath) {
2614+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
2615+ }
26212616 process.stdout.write(os.EOL);
2622- command_1.issueCommand('set-output', { name }, value);
2617+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
26232618}
26242619exports.setOutput = setOutput;
26252620/**
@@ -2748,7 +2743,11 @@ exports.group = group;
27482743 */
27492744// eslint-disable-next-line @typescript-eslint/no-explicit-any
27502745function saveState(name, value) {
2751- command_1.issueCommand('save-state', { name }, value);
2746+ const filePath = process.env['GITHUB_STATE'] || '';
2747+ if (filePath) {
2748+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
2749+ }
2750+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
27522751}
27532752exports.saveState = saveState;
27542753/**
@@ -2814,13 +2813,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
28142813 return result;
28152814};
28162815Object.defineProperty(exports, "__esModule", ({ value: true }));
2817- exports.issueCommand = void 0;
2816+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
28182817// We use any as a valid input type
28192818/* eslint-disable @typescript-eslint/no-explicit-any */
28202819const fs = __importStar(__nccwpck_require__(5747));
28212820const os = __importStar(__nccwpck_require__(2087));
2821+ const uuid_1 = __nccwpck_require__(5840);
28222822const utils_1 = __nccwpck_require__(5278);
2823- function issueCommand (command, message) {
2823+ function issueFileCommand (command, message) {
28242824 const filePath = process.env[`GITHUB_${command}`];
28252825 if (!filePath) {
28262826 throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -2832,7 +2832,22 @@ function issueCommand(command, message) {
28322832 encoding: 'utf8'
28332833 });
28342834}
2835- exports.issueCommand = issueCommand;
2835+ exports.issueFileCommand = issueFileCommand;
2836+ function prepareKeyValueMessage(key, value) {
2837+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
2838+ const convertedValue = utils_1.toCommandValue(value);
2839+ // These should realistically never happen, but just in case someone finds a
2840+ // way to exploit uuid generation let's not allow keys or values that contain
2841+ // the delimiter.
2842+ if (key.includes(delimiter)) {
2843+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
2844+ }
2845+ if (convertedValue.includes(delimiter)) {
2846+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
2847+ }
2848+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
2849+ }
2850+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
28362851//# sourceMappingURL=file-command.js.map
28372852
28382853/***/ }),
0 commit comments