@@ -383,7 +383,6 @@ const file_command_1 = __nccwpck_require__(717);
383
383
const utils_1 = __nccwpck_require__(5278);
384
384
const os = __importStar(__nccwpck_require__(2037));
385
385
const path = __importStar(__nccwpck_require__(1017));
386
- const uuid_1 = __nccwpck_require__(5840);
387
386
const oidc_utils_1 = __nccwpck_require__(8041);
388
387
/**
389
388
* The code to exit an action
@@ -413,20 +412,9 @@ function exportVariable(name, val) {
413
412
process.env[name] = convertedVal;
414
413
const filePath = process.env['GITHUB_ENV'] || '';
415
414
if (filePath) {
416
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
417
- // 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.
418
- if (name.includes(delimiter)) {
419
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
420
- }
421
- if (convertedVal.includes(delimiter)) {
422
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
423
- }
424
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
425
- file_command_1.issueCommand('ENV', commandValue);
426
- }
427
- else {
428
- command_1.issueCommand('set-env', { name }, convertedVal);
415
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
429
416
}
417
+ command_1.issueCommand('set-env', { name }, convertedVal);
430
418
}
431
419
exports.exportVariable = exportVariable;
432
420
/**
@@ -444,7 +432,7 @@ exports.setSecret = setSecret;
444
432
function addPath(inputPath) {
445
433
const filePath = process.env['GITHUB_PATH'] || '';
446
434
if (filePath) {
447
- file_command_1.issueCommand ('PATH', inputPath);
435
+ file_command_1.issueFileCommand ('PATH', inputPath);
448
436
}
449
437
else {
450
438
command_1.issueCommand('add-path', {}, inputPath);
@@ -484,7 +472,10 @@ function getMultilineInput(name, options) {
484
472
const inputs = getInput(name, options)
485
473
.split('\n')
486
474
.filter(x => x !== '');
487
- return inputs;
475
+ if (options && options.trimWhitespace === false) {
476
+ return inputs;
477
+ }
478
+ return inputs.map(input => input.trim());
488
479
}
489
480
exports.getMultilineInput = getMultilineInput;
490
481
/**
@@ -517,8 +508,12 @@ exports.getBooleanInput = getBooleanInput;
517
508
*/
518
509
// eslint-disable-next-line @typescript-eslint/no-explicit-any
519
510
function setOutput(name, value) {
511
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
512
+ if (filePath) {
513
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
514
+ }
520
515
process.stdout.write(os.EOL);
521
- command_1.issueCommand('set-output', { name }, value);
516
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
522
517
}
523
518
exports.setOutput = setOutput;
524
519
/**
@@ -647,7 +642,11 @@ exports.group = group;
647
642
*/
648
643
// eslint-disable-next-line @typescript-eslint/no-explicit-any
649
644
function saveState(name, value) {
650
- command_1.issueCommand('save-state', { name }, value);
645
+ const filePath = process.env['GITHUB_STATE'] || '';
646
+ if (filePath) {
647
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
648
+ }
649
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
651
650
}
652
651
exports.saveState = saveState;
653
652
/**
@@ -713,13 +712,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
713
712
return result;
714
713
};
715
714
Object.defineProperty(exports, "__esModule", ({ value: true }));
716
- exports.issueCommand = void 0;
715
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
717
716
// We use any as a valid input type
718
717
/* eslint-disable @typescript-eslint/no-explicit-any */
719
718
const fs = __importStar(__nccwpck_require__(7147));
720
719
const os = __importStar(__nccwpck_require__(2037));
720
+ const uuid_1 = __nccwpck_require__(5840);
721
721
const utils_1 = __nccwpck_require__(5278);
722
- function issueCommand (command, message) {
722
+ function issueFileCommand (command, message) {
723
723
const filePath = process.env[`GITHUB_${command}`];
724
724
if (!filePath) {
725
725
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -731,7 +731,22 @@ function issueCommand(command, message) {
731
731
encoding: 'utf8'
732
732
});
733
733
}
734
- exports.issueCommand = issueCommand;
734
+ exports.issueFileCommand = issueFileCommand;
735
+ function prepareKeyValueMessage(key, value) {
736
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
737
+ const convertedValue = utils_1.toCommandValue(value);
738
+ // These should realistically never happen, but just in case someone finds a
739
+ // way to exploit uuid generation let's not allow keys or values that contain
740
+ // the delimiter.
741
+ if (key.includes(delimiter)) {
742
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
743
+ }
744
+ if (convertedValue.includes(delimiter)) {
745
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
746
+ }
747
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
748
+ }
749
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
735
750
//# sourceMappingURL=file-command.js.map
736
751
737
752
/***/ }),
0 commit comments