@@ -5217,7 +5217,6 @@ const file_command_1 = __webpack_require__(717);
5217
5217
const utils_1 = __webpack_require__(278);
5218
5218
const os = __importStar(__webpack_require__(87));
5219
5219
const path = __importStar(__webpack_require__(622));
5220
- const uuid_1 = __webpack_require__(840);
5221
5220
const oidc_utils_1 = __webpack_require__(41);
5222
5221
/**
5223
5222
* The code to exit an action
@@ -5247,20 +5246,9 @@ function exportVariable(name, val) {
5247
5246
process.env[name] = convertedVal;
5248
5247
const filePath = process.env['GITHUB_ENV'] || '';
5249
5248
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));
5263
5250
}
5251
+ command_1.issueCommand('set-env', { name }, convertedVal);
5264
5252
}
5265
5253
exports.exportVariable = exportVariable;
5266
5254
/**
@@ -5278,7 +5266,7 @@ exports.setSecret = setSecret;
5278
5266
function addPath(inputPath) {
5279
5267
const filePath = process.env['GITHUB_PATH'] || '';
5280
5268
if (filePath) {
5281
- file_command_1.issueCommand ('PATH', inputPath);
5269
+ file_command_1.issueFileCommand ('PATH', inputPath);
5282
5270
}
5283
5271
else {
5284
5272
command_1.issueCommand('add-path', {}, inputPath);
@@ -5318,7 +5306,10 @@ function getMultilineInput(name, options) {
5318
5306
const inputs = getInput(name, options)
5319
5307
.split('\n')
5320
5308
.filter(x => x !== '');
5321
- return inputs;
5309
+ if (options && options.trimWhitespace === false) {
5310
+ return inputs;
5311
+ }
5312
+ return inputs.map(input => input.trim());
5322
5313
}
5323
5314
exports.getMultilineInput = getMultilineInput;
5324
5315
/**
@@ -5351,8 +5342,12 @@ exports.getBooleanInput = getBooleanInput;
5351
5342
*/
5352
5343
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5353
5344
function 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
+ }
5354
5349
process.stdout.write(os.EOL);
5355
- command_1.issueCommand('set-output', { name }, value);
5350
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
5356
5351
}
5357
5352
exports.setOutput = setOutput;
5358
5353
/**
@@ -5481,7 +5476,11 @@ exports.group = group;
5481
5476
*/
5482
5477
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5483
5478
function 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));
5485
5484
}
5486
5485
exports.saveState = saveState;
5487
5486
/**
@@ -12117,13 +12116,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
12117
12116
return result;
12118
12117
};
12119
12118
Object.defineProperty(exports, "__esModule", { value: true });
12120
- exports.issueCommand = void 0;
12119
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
12121
12120
// We use any as a valid input type
12122
12121
/* eslint-disable @typescript-eslint/no-explicit-any */
12123
12122
const fs = __importStar(__webpack_require__(747));
12124
12123
const os = __importStar(__webpack_require__(87));
12124
+ const uuid_1 = __webpack_require__(840);
12125
12125
const utils_1 = __webpack_require__(278);
12126
- function issueCommand (command, message) {
12126
+ function issueFileCommand (command, message) {
12127
12127
const filePath = process.env[`GITHUB_${command}`];
12128
12128
if (!filePath) {
12129
12129
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -12135,7 +12135,22 @@ function issueCommand(command, message) {
12135
12135
encoding: 'utf8'
12136
12136
});
12137
12137
}
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;
12139
12154
//# sourceMappingURL=file-command.js.map
12140
12155
12141
12156
/***/ }),
0 commit comments