@@ -3605,7 +3605,6 @@ const file_command_1 = __webpack_require__(717);
3605
3605
const utils_1 = __webpack_require__(278);
3606
3606
const os = __importStar(__webpack_require__(87));
3607
3607
const path = __importStar(__webpack_require__(622));
3608
- const uuid_1 = __webpack_require__(840);
3609
3608
const oidc_utils_1 = __webpack_require__(41);
3610
3609
/**
3611
3610
* The code to exit an action
@@ -3635,20 +3634,9 @@ function exportVariable(name, val) {
3635
3634
process.env[name] = convertedVal;
3636
3635
const filePath = process.env['GITHUB_ENV'] || '';
3637
3636
if (filePath) {
3638
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
3639
- // 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.
3640
- if (name.includes(delimiter)) {
3641
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
3642
- }
3643
- if (convertedVal.includes(delimiter)) {
3644
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
3645
- }
3646
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
3647
- file_command_1.issueCommand('ENV', commandValue);
3648
- }
3649
- else {
3650
- command_1.issueCommand('set-env', { name }, convertedVal);
3637
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
3651
3638
}
3639
+ command_1.issueCommand('set-env', { name }, convertedVal);
3652
3640
}
3653
3641
exports.exportVariable = exportVariable;
3654
3642
/**
@@ -3666,7 +3654,7 @@ exports.setSecret = setSecret;
3666
3654
function addPath(inputPath) {
3667
3655
const filePath = process.env['GITHUB_PATH'] || '';
3668
3656
if (filePath) {
3669
- file_command_1.issueCommand ('PATH', inputPath);
3657
+ file_command_1.issueFileCommand ('PATH', inputPath);
3670
3658
}
3671
3659
else {
3672
3660
command_1.issueCommand('add-path', {}, inputPath);
@@ -3706,7 +3694,10 @@ function getMultilineInput(name, options) {
3706
3694
const inputs = getInput(name, options)
3707
3695
.split('\n')
3708
3696
.filter(x => x !== '');
3709
- return inputs;
3697
+ if (options && options.trimWhitespace === false) {
3698
+ return inputs;
3699
+ }
3700
+ return inputs.map(input => input.trim());
3710
3701
}
3711
3702
exports.getMultilineInput = getMultilineInput;
3712
3703
/**
@@ -3739,8 +3730,12 @@ exports.getBooleanInput = getBooleanInput;
3739
3730
*/
3740
3731
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3741
3732
function setOutput(name, value) {
3733
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
3734
+ if (filePath) {
3735
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
3736
+ }
3742
3737
process.stdout.write(os.EOL);
3743
- command_1.issueCommand('set-output', { name }, value);
3738
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
3744
3739
}
3745
3740
exports.setOutput = setOutput;
3746
3741
/**
@@ -3869,7 +3864,11 @@ exports.group = group;
3869
3864
*/
3870
3865
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3871
3866
function saveState(name, value) {
3872
- command_1.issueCommand('save-state', { name }, value);
3867
+ const filePath = process.env['GITHUB_STATE'] || '';
3868
+ if (filePath) {
3869
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
3870
+ }
3871
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
3873
3872
}
3874
3873
exports.saveState = saveState;
3875
3874
/**
@@ -10561,13 +10560,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
10561
10560
return result;
10562
10561
};
10563
10562
Object.defineProperty(exports, "__esModule", { value: true });
10564
- exports.issueCommand = void 0;
10563
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
10565
10564
// We use any as a valid input type
10566
10565
/* eslint-disable @typescript-eslint/no-explicit-any */
10567
10566
const fs = __importStar(__webpack_require__(747));
10568
10567
const os = __importStar(__webpack_require__(87));
10568
+ const uuid_1 = __webpack_require__(840);
10569
10569
const utils_1 = __webpack_require__(278);
10570
- function issueCommand (command, message) {
10570
+ function issueFileCommand (command, message) {
10571
10571
const filePath = process.env[`GITHUB_${command}`];
10572
10572
if (!filePath) {
10573
10573
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -10579,7 +10579,22 @@ function issueCommand(command, message) {
10579
10579
encoding: 'utf8'
10580
10580
});
10581
10581
}
10582
- exports.issueCommand = issueCommand;
10582
+ exports.issueFileCommand = issueFileCommand;
10583
+ function prepareKeyValueMessage(key, value) {
10584
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
10585
+ const convertedValue = utils_1.toCommandValue(value);
10586
+ // These should realistically never happen, but just in case someone finds a
10587
+ // way to exploit uuid generation let's not allow keys or values that contain
10588
+ // the delimiter.
10589
+ if (key.includes(delimiter)) {
10590
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
10591
+ }
10592
+ if (convertedValue.includes(delimiter)) {
10593
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
10594
+ }
10595
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
10596
+ }
10597
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
10583
10598
//# sourceMappingURL=file-command.js.map
10584
10599
10585
10600
/***/ }),
0 commit comments