@@ -5217,7 +5217,6 @@ const file_command_1 = __webpack_require__(717);
52175217const utils_1 = __webpack_require__(278);
52185218const os = __importStar(__webpack_require__(87));
52195219const path = __importStar(__webpack_require__(622));
5220- const uuid_1 = __webpack_require__(840);
52215220const oidc_utils_1 = __webpack_require__(41);
52225221/**
52235222 * The code to exit an action
@@ -5247,20 +5246,9 @@ function exportVariable(name, val) {
52475246 process.env[name] = convertedVal;
52485247 const filePath = process.env['GITHUB_ENV'] || '';
52495248 if (filePath) {
5250- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
5251- // 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.
5252- if (name.includes(delimiter)) {
5253- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
5254- }
5255- if (convertedVal.includes(delimiter)) {
5256- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
5257- }
5258- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
5259- file_command_1.issueCommand('ENV', commandValue);
5260- }
5261- else {
5262- command_1.issueCommand('set-env', { name }, convertedVal);
5249+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
52635250 }
5251+ command_1.issueCommand('set-env', { name }, convertedVal);
52645252}
52655253exports.exportVariable = exportVariable;
52665254/**
@@ -5278,7 +5266,7 @@ exports.setSecret = setSecret;
52785266function addPath(inputPath) {
52795267 const filePath = process.env['GITHUB_PATH'] || '';
52805268 if (filePath) {
5281- file_command_1.issueCommand ('PATH', inputPath);
5269+ file_command_1.issueFileCommand ('PATH', inputPath);
52825270 }
52835271 else {
52845272 command_1.issueCommand('add-path', {}, inputPath);
@@ -5318,7 +5306,10 @@ function getMultilineInput(name, options) {
53185306 const inputs = getInput(name, options)
53195307 .split('\n')
53205308 .filter(x => x !== '');
5321- return inputs;
5309+ if (options && options.trimWhitespace === false) {
5310+ return inputs;
5311+ }
5312+ return inputs.map(input => input.trim());
53225313}
53235314exports.getMultilineInput = getMultilineInput;
53245315/**
@@ -5351,8 +5342,12 @@ exports.getBooleanInput = getBooleanInput;
53515342 */
53525343// eslint-disable-next-line @typescript-eslint/no-explicit-any
53535344function setOutput(name, value) {
5345+ const filePath = process.env['GITHUB_OUTPUT'] || '';
5346+ if (filePath) {
5347+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
5348+ }
53545349 process.stdout.write(os.EOL);
5355- command_1.issueCommand('set-output', { name }, value);
5350+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
53565351}
53575352exports.setOutput = setOutput;
53585353/**
@@ -5481,7 +5476,11 @@ exports.group = group;
54815476 */
54825477// eslint-disable-next-line @typescript-eslint/no-explicit-any
54835478function saveState(name, value) {
5484- command_1.issueCommand('save-state', { name }, value);
5479+ const filePath = process.env['GITHUB_STATE'] || '';
5480+ if (filePath) {
5481+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
5482+ }
5483+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
54855484}
54865485exports.saveState = saveState;
54875486/**
@@ -12117,13 +12116,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
1211712116 return result;
1211812117};
1211912118Object.defineProperty(exports, "__esModule", { value: true });
12120- exports.issueCommand = void 0;
12119+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
1212112120// We use any as a valid input type
1212212121/* eslint-disable @typescript-eslint/no-explicit-any */
1212312122const fs = __importStar(__webpack_require__(747));
1212412123const os = __importStar(__webpack_require__(87));
12124+ const uuid_1 = __webpack_require__(840);
1212512125const utils_1 = __webpack_require__(278);
12126- function issueCommand (command, message) {
12126+ function issueFileCommand (command, message) {
1212712127 const filePath = process.env[`GITHUB_${command}`];
1212812128 if (!filePath) {
1212912129 throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -12135,7 +12135,22 @@ function issueCommand(command, message) {
1213512135 encoding: 'utf8'
1213612136 });
1213712137}
12138- exports.issueCommand = issueCommand;
12138+ exports.issueFileCommand = issueFileCommand;
12139+ function prepareKeyValueMessage(key, value) {
12140+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
12141+ const convertedValue = utils_1.toCommandValue(value);
12142+ // These should realistically never happen, but just in case someone finds a
12143+ // way to exploit uuid generation let's not allow keys or values that contain
12144+ // the delimiter.
12145+ if (key.includes(delimiter)) {
12146+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
12147+ }
12148+ if (convertedValue.includes(delimiter)) {
12149+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
12150+ }
12151+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
12152+ }
12153+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
1213912154//# sourceMappingURL=file-command.js.map
1214012155
1214112156/***/ }),
0 commit comments