@@ -3605,7 +3605,6 @@ const file_command_1 = __webpack_require__(717);
36053605const utils_1 = __webpack_require__(278);
36063606const os = __importStar(__webpack_require__(87));
36073607const path = __importStar(__webpack_require__(622));
3608- const uuid_1 = __webpack_require__(840);
36093608const oidc_utils_1 = __webpack_require__(41);
36103609/**
36113610 * The code to exit an action
@@ -3635,20 +3634,9 @@ function exportVariable(name, val) {
36353634 process.env[name] = convertedVal;
36363635 const filePath = process.env['GITHUB_ENV'] || '';
36373636 if (filePath) {
3638- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
3639- // 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.
3640- if (name.includes(delimiter)) {
3641- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
3642- }
3643- if (convertedVal.includes(delimiter)) {
3644- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
3645- }
3646- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
3647- file_command_1.issueCommand('ENV', commandValue);
3648- }
3649- else {
3650- command_1.issueCommand('set-env', { name }, convertedVal);
3637+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
36513638 }
3639+ command_1.issueCommand('set-env', { name }, convertedVal);
36523640}
36533641exports.exportVariable = exportVariable;
36543642/**
@@ -3666,7 +3654,7 @@ exports.setSecret = setSecret;
36663654function addPath(inputPath) {
36673655 const filePath = process.env['GITHUB_PATH'] || '';
36683656 if (filePath) {
3669- file_command_1.issueCommand ('PATH', inputPath);
3657+ file_command_1.issueFileCommand ('PATH', inputPath);
36703658 }
36713659 else {
36723660 command_1.issueCommand('add-path', {}, inputPath);
@@ -3706,7 +3694,10 @@ function getMultilineInput(name, options) {
37063694 const inputs = getInput(name, options)
37073695 .split('\n')
37083696 .filter(x => x !== '');
3709- return inputs;
3697+ if (options && options.trimWhitespace === false) {
3698+ return inputs;
3699+ }
3700+ return inputs.map(input => input.trim());
37103701}
37113702exports.getMultilineInput = getMultilineInput;
37123703/**
@@ -3739,8 +3730,12 @@ exports.getBooleanInput = getBooleanInput;
37393730 */
37403731// eslint-disable-next-line @typescript-eslint/no-explicit-any
37413732function setOutput(name, value) {
3733+ const filePath = process.env['GITHUB_OUTPUT'] || '';
3734+ if (filePath) {
3735+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
3736+ }
37423737 process.stdout.write(os.EOL);
3743- command_1.issueCommand('set-output', { name }, value);
3738+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
37443739}
37453740exports.setOutput = setOutput;
37463741/**
@@ -3869,7 +3864,11 @@ exports.group = group;
38693864 */
38703865// eslint-disable-next-line @typescript-eslint/no-explicit-any
38713866function saveState(name, value) {
3872- command_1.issueCommand('save-state', { name }, value);
3867+ const filePath = process.env['GITHUB_STATE'] || '';
3868+ if (filePath) {
3869+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
3870+ }
3871+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
38733872}
38743873exports.saveState = saveState;
38753874/**
@@ -10561,13 +10560,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
1056110560 return result;
1056210561};
1056310562Object.defineProperty(exports, "__esModule", { value: true });
10564- exports.issueCommand = void 0;
10563+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
1056510564// We use any as a valid input type
1056610565/* eslint-disable @typescript-eslint/no-explicit-any */
1056710566const fs = __importStar(__webpack_require__(747));
1056810567const os = __importStar(__webpack_require__(87));
10568+ const uuid_1 = __webpack_require__(840);
1056910569const utils_1 = __webpack_require__(278);
10570- function issueCommand (command, message) {
10570+ function issueFileCommand (command, message) {
1057110571 const filePath = process.env[`GITHUB_${command}`];
1057210572 if (!filePath) {
1057310573 throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -10579,7 +10579,22 @@ function issueCommand(command, message) {
1057910579 encoding: 'utf8'
1058010580 });
1058110581}
10582- exports.issueCommand = issueCommand;
10582+ exports.issueFileCommand = issueFileCommand;
10583+ function prepareKeyValueMessage(key, value) {
10584+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
10585+ const convertedValue = utils_1.toCommandValue(value);
10586+ // These should realistically never happen, but just in case someone finds a
10587+ // way to exploit uuid generation let's not allow keys or values that contain
10588+ // the delimiter.
10589+ if (key.includes(delimiter)) {
10590+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
10591+ }
10592+ if (convertedValue.includes(delimiter)) {
10593+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
10594+ }
10595+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
10596+ }
10597+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
1058310598//# sourceMappingURL=file-command.js.map
1058410599
1058510600/***/ }),
0 commit comments