@@ -2484,7 +2484,6 @@ const file_command_1 = __nccwpck_require__(717);
2484
2484
const utils_1 = __nccwpck_require__(5278);
2485
2485
const os = __importStar(__nccwpck_require__(2087));
2486
2486
const path = __importStar(__nccwpck_require__(5622));
2487
- const uuid_1 = __nccwpck_require__(5840);
2488
2487
const oidc_utils_1 = __nccwpck_require__(8041);
2489
2488
/**
2490
2489
* The code to exit an action
@@ -2514,20 +2513,9 @@ function exportVariable(name, val) {
2514
2513
process.env[name] = convertedVal;
2515
2514
const filePath = process.env['GITHUB_ENV'] || '';
2516
2515
if (filePath) {
2517
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
2518
- // 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.
2519
- if (name.includes(delimiter)) {
2520
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
2521
- }
2522
- if (convertedVal.includes(delimiter)) {
2523
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
2524
- }
2525
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
2526
- file_command_1.issueCommand('ENV', commandValue);
2527
- }
2528
- else {
2529
- command_1.issueCommand('set-env', { name }, convertedVal);
2516
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
2530
2517
}
2518
+ command_1.issueCommand('set-env', { name }, convertedVal);
2531
2519
}
2532
2520
exports.exportVariable = exportVariable;
2533
2521
/**
@@ -2545,7 +2533,7 @@ exports.setSecret = setSecret;
2545
2533
function addPath(inputPath) {
2546
2534
const filePath = process.env['GITHUB_PATH'] || '';
2547
2535
if (filePath) {
2548
- file_command_1.issueCommand ('PATH', inputPath);
2536
+ file_command_1.issueFileCommand ('PATH', inputPath);
2549
2537
}
2550
2538
else {
2551
2539
command_1.issueCommand('add-path', {}, inputPath);
@@ -2585,7 +2573,10 @@ function getMultilineInput(name, options) {
2585
2573
const inputs = getInput(name, options)
2586
2574
.split('\n')
2587
2575
.filter(x => x !== '');
2588
- return inputs;
2576
+ if (options && options.trimWhitespace === false) {
2577
+ return inputs;
2578
+ }
2579
+ return inputs.map(input => input.trim());
2589
2580
}
2590
2581
exports.getMultilineInput = getMultilineInput;
2591
2582
/**
@@ -2618,8 +2609,12 @@ exports.getBooleanInput = getBooleanInput;
2618
2609
*/
2619
2610
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2620
2611
function setOutput(name, value) {
2612
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
2613
+ if (filePath) {
2614
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
2615
+ }
2621
2616
process.stdout.write(os.EOL);
2622
- command_1.issueCommand('set-output', { name }, value);
2617
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
2623
2618
}
2624
2619
exports.setOutput = setOutput;
2625
2620
/**
@@ -2748,7 +2743,11 @@ exports.group = group;
2748
2743
*/
2749
2744
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2750
2745
function saveState(name, value) {
2751
- command_1.issueCommand('save-state', { name }, value);
2746
+ const filePath = process.env['GITHUB_STATE'] || '';
2747
+ if (filePath) {
2748
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
2749
+ }
2750
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
2752
2751
}
2753
2752
exports.saveState = saveState;
2754
2753
/**
@@ -2814,13 +2813,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
2814
2813
return result;
2815
2814
};
2816
2815
Object.defineProperty(exports, "__esModule", ({ value: true }));
2817
- exports.issueCommand = void 0;
2816
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
2818
2817
// We use any as a valid input type
2819
2818
/* eslint-disable @typescript-eslint/no-explicit-any */
2820
2819
const fs = __importStar(__nccwpck_require__(5747));
2821
2820
const os = __importStar(__nccwpck_require__(2087));
2821
+ const uuid_1 = __nccwpck_require__(5840);
2822
2822
const utils_1 = __nccwpck_require__(5278);
2823
- function issueCommand (command, message) {
2823
+ function issueFileCommand (command, message) {
2824
2824
const filePath = process.env[`GITHUB_${command}`];
2825
2825
if (!filePath) {
2826
2826
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -2832,7 +2832,22 @@ function issueCommand(command, message) {
2832
2832
encoding: 'utf8'
2833
2833
});
2834
2834
}
2835
- exports.issueCommand = issueCommand;
2835
+ exports.issueFileCommand = issueFileCommand;
2836
+ function prepareKeyValueMessage(key, value) {
2837
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
2838
+ const convertedValue = utils_1.toCommandValue(value);
2839
+ // These should realistically never happen, but just in case someone finds a
2840
+ // way to exploit uuid generation let's not allow keys or values that contain
2841
+ // the delimiter.
2842
+ if (key.includes(delimiter)) {
2843
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
2844
+ }
2845
+ if (convertedValue.includes(delimiter)) {
2846
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
2847
+ }
2848
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
2849
+ }
2850
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
2836
2851
//# sourceMappingURL=file-command.js.map
2837
2852
2838
2853
/***/ }),
0 commit comments