@@ -307,7 +307,6 @@ const file_command_1 = __nccwpck_require__(717);
307
307
const utils_1 = __nccwpck_require__(5278);
308
308
const os = __importStar(__nccwpck_require__(2037));
309
309
const path = __importStar(__nccwpck_require__(1017));
310
- const uuid_1 = __nccwpck_require__(5840);
311
310
const oidc_utils_1 = __nccwpck_require__(8041);
312
311
/**
313
312
* The code to exit an action
@@ -337,20 +336,9 @@ function exportVariable(name, val) {
337
336
process.env[name] = convertedVal;
338
337
const filePath = process.env['GITHUB_ENV'] || '';
339
338
if (filePath) {
340
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
341
- // 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.
342
- if (name.includes(delimiter)) {
343
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
344
- }
345
- if (convertedVal.includes(delimiter)) {
346
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
347
- }
348
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
349
- file_command_1.issueCommand('ENV', commandValue);
350
- }
351
- else {
352
- command_1.issueCommand('set-env', { name }, convertedVal);
339
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
353
340
}
341
+ command_1.issueCommand('set-env', { name }, convertedVal);
354
342
}
355
343
exports.exportVariable = exportVariable;
356
344
/**
@@ -368,7 +356,7 @@ exports.setSecret = setSecret;
368
356
function addPath(inputPath) {
369
357
const filePath = process.env['GITHUB_PATH'] || '';
370
358
if (filePath) {
371
- file_command_1.issueCommand ('PATH', inputPath);
359
+ file_command_1.issueFileCommand ('PATH', inputPath);
372
360
}
373
361
else {
374
362
command_1.issueCommand('add-path', {}, inputPath);
@@ -408,7 +396,10 @@ function getMultilineInput(name, options) {
408
396
const inputs = getInput(name, options)
409
397
.split('\n')
410
398
.filter(x => x !== '');
411
- return inputs;
399
+ if (options && options.trimWhitespace === false) {
400
+ return inputs;
401
+ }
402
+ return inputs.map(input => input.trim());
412
403
}
413
404
exports.getMultilineInput = getMultilineInput;
414
405
/**
@@ -441,8 +432,12 @@ exports.getBooleanInput = getBooleanInput;
441
432
*/
442
433
// eslint-disable-next-line @typescript-eslint/no-explicit-any
443
434
function setOutput(name, value) {
435
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
436
+ if (filePath) {
437
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
438
+ }
444
439
process.stdout.write(os.EOL);
445
- command_1.issueCommand('set-output', { name }, value);
440
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
446
441
}
447
442
exports.setOutput = setOutput;
448
443
/**
@@ -571,7 +566,11 @@ exports.group = group;
571
566
*/
572
567
// eslint-disable-next-line @typescript-eslint/no-explicit-any
573
568
function saveState(name, value) {
574
- command_1.issueCommand('save-state', { name }, value);
569
+ const filePath = process.env['GITHUB_STATE'] || '';
570
+ if (filePath) {
571
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
572
+ }
573
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
575
574
}
576
575
exports.saveState = saveState;
577
576
/**
@@ -637,13 +636,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
637
636
return result;
638
637
};
639
638
Object.defineProperty(exports, "__esModule", ({ value: true }));
640
- exports.issueCommand = void 0;
639
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
641
640
// We use any as a valid input type
642
641
/* eslint-disable @typescript-eslint/no-explicit-any */
643
642
const fs = __importStar(__nccwpck_require__(7147));
644
643
const os = __importStar(__nccwpck_require__(2037));
644
+ const uuid_1 = __nccwpck_require__(5840);
645
645
const utils_1 = __nccwpck_require__(5278);
646
- function issueCommand (command, message) {
646
+ function issueFileCommand (command, message) {
647
647
const filePath = process.env[`GITHUB_${command}`];
648
648
if (!filePath) {
649
649
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -655,7 +655,22 @@ function issueCommand(command, message) {
655
655
encoding: 'utf8'
656
656
});
657
657
}
658
- exports.issueCommand = issueCommand;
658
+ exports.issueFileCommand = issueFileCommand;
659
+ function prepareKeyValueMessage(key, value) {
660
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
661
+ const convertedValue = utils_1.toCommandValue(value);
662
+ // These should realistically never happen, but just in case someone finds a
663
+ // way to exploit uuid generation let's not allow keys or values that contain
664
+ // the delimiter.
665
+ if (key.includes(delimiter)) {
666
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
667
+ }
668
+ if (convertedValue.includes(delimiter)) {
669
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
670
+ }
671
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
672
+ }
673
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
659
674
//# sourceMappingURL=file-command.js.map
660
675
661
676
/***/ }),
0 commit comments