@@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717);
140
140
const utils_1 = __nccwpck_require__(5278);
141
141
const os = __importStar(__nccwpck_require__(2037));
142
142
const path = __importStar(__nccwpck_require__(1017));
143
- const uuid_1 = __nccwpck_require__(5840);
144
143
const oidc_utils_1 = __nccwpck_require__(8041);
145
144
/**
146
145
* The code to exit an action
@@ -170,20 +169,9 @@ function exportVariable(name, val) {
170
169
process.env[name] = convertedVal;
171
170
const filePath = process.env['GITHUB_ENV'] || '';
172
171
if (filePath) {
173
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
174
- // 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.
175
- if (name.includes(delimiter)) {
176
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
177
- }
178
- if (convertedVal.includes(delimiter)) {
179
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
180
- }
181
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
182
- file_command_1.issueCommand('ENV', commandValue);
183
- }
184
- else {
185
- command_1.issueCommand('set-env', { name }, convertedVal);
172
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
186
173
}
174
+ command_1.issueCommand('set-env', { name }, convertedVal);
187
175
}
188
176
exports.exportVariable = exportVariable;
189
177
/**
@@ -201,7 +189,7 @@ exports.setSecret = setSecret;
201
189
function addPath(inputPath) {
202
190
const filePath = process.env['GITHUB_PATH'] || '';
203
191
if (filePath) {
204
- file_command_1.issueCommand ('PATH', inputPath);
192
+ file_command_1.issueFileCommand ('PATH', inputPath);
205
193
}
206
194
else {
207
195
command_1.issueCommand('add-path', {}, inputPath);
@@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
241
229
const inputs = getInput(name, options)
242
230
.split('\n')
243
231
.filter(x => x !== '');
244
- return inputs;
232
+ if (options && options.trimWhitespace === false) {
233
+ return inputs;
234
+ }
235
+ return inputs.map(input => input.trim());
245
236
}
246
237
exports.getMultilineInput = getMultilineInput;
247
238
/**
@@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
274
265
*/
275
266
// eslint-disable-next-line @typescript-eslint/no-explicit-any
276
267
function setOutput(name, value) {
268
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
269
+ if (filePath) {
270
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
271
+ }
277
272
process.stdout.write(os.EOL);
278
- command_1.issueCommand('set-output', { name }, value);
273
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
279
274
}
280
275
exports.setOutput = setOutput;
281
276
/**
@@ -404,7 +399,11 @@ exports.group = group;
404
399
*/
405
400
// eslint-disable-next-line @typescript-eslint/no-explicit-any
406
401
function saveState(name, value) {
407
- command_1.issueCommand('save-state', { name }, value);
402
+ const filePath = process.env['GITHUB_STATE'] || '';
403
+ if (filePath) {
404
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
405
+ }
406
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
408
407
}
409
408
exports.saveState = saveState;
410
409
/**
@@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
470
469
return result;
471
470
};
472
471
Object.defineProperty(exports, "__esModule", ({ value: true }));
473
- exports.issueCommand = void 0;
472
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
474
473
// We use any as a valid input type
475
474
/* eslint-disable @typescript-eslint/no-explicit-any */
476
475
const fs = __importStar(__nccwpck_require__(7147));
477
476
const os = __importStar(__nccwpck_require__(2037));
477
+ const uuid_1 = __nccwpck_require__(5840);
478
478
const utils_1 = __nccwpck_require__(5278);
479
- function issueCommand (command, message) {
479
+ function issueFileCommand (command, message) {
480
480
const filePath = process.env[`GITHUB_${command}`];
481
481
if (!filePath) {
482
482
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -488,7 +488,22 @@ function issueCommand(command, message) {
488
488
encoding: 'utf8'
489
489
});
490
490
}
491
- exports.issueCommand = issueCommand;
491
+ exports.issueFileCommand = issueFileCommand;
492
+ function prepareKeyValueMessage(key, value) {
493
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
494
+ const convertedValue = utils_1.toCommandValue(value);
495
+ // These should realistically never happen, but just in case someone finds a
496
+ // way to exploit uuid generation let's not allow keys or values that contain
497
+ // the delimiter.
498
+ if (key.includes(delimiter)) {
499
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
500
+ }
501
+ if (convertedValue.includes(delimiter)) {
502
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
503
+ }
504
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
505
+ }
506
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
492
507
//# sourceMappingURL=file-command.js.map
493
508
494
509
/***/ }),
0 commit comments