@@ -775,7 +775,6 @@ const file_command_1 = __nccwpck_require__(717);
775
775
const utils_1 = __nccwpck_require__(5278);
776
776
const os = __importStar(__nccwpck_require__(2037));
777
777
const path = __importStar(__nccwpck_require__(1017));
778
- const uuid_1 = __nccwpck_require__(5840);
779
778
const oidc_utils_1 = __nccwpck_require__(8041);
780
779
/**
781
780
* The code to exit an action
@@ -805,20 +804,9 @@ function exportVariable(name, val) {
805
804
process.env[name] = convertedVal;
806
805
const filePath = process.env['GITHUB_ENV'] || '';
807
806
if (filePath) {
808
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
809
- // 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.
810
- if (name.includes(delimiter)) {
811
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
812
- }
813
- if (convertedVal.includes(delimiter)) {
814
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
815
- }
816
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
817
- file_command_1.issueCommand('ENV', commandValue);
818
- }
819
- else {
820
- command_1.issueCommand('set-env', { name }, convertedVal);
807
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
821
808
}
809
+ command_1.issueCommand('set-env', { name }, convertedVal);
822
810
}
823
811
exports.exportVariable = exportVariable;
824
812
/**
@@ -836,7 +824,7 @@ exports.setSecret = setSecret;
836
824
function addPath(inputPath) {
837
825
const filePath = process.env['GITHUB_PATH'] || '';
838
826
if (filePath) {
839
- file_command_1.issueCommand ('PATH', inputPath);
827
+ file_command_1.issueFileCommand ('PATH', inputPath);
840
828
}
841
829
else {
842
830
command_1.issueCommand('add-path', {}, inputPath);
@@ -876,7 +864,10 @@ function getMultilineInput(name, options) {
876
864
const inputs = getInput(name, options)
877
865
.split('\n')
878
866
.filter(x => x !== '');
879
- return inputs;
867
+ if (options && options.trimWhitespace === false) {
868
+ return inputs;
869
+ }
870
+ return inputs.map(input => input.trim());
880
871
}
881
872
exports.getMultilineInput = getMultilineInput;
882
873
/**
@@ -909,8 +900,12 @@ exports.getBooleanInput = getBooleanInput;
909
900
*/
910
901
// eslint-disable-next-line @typescript-eslint/no-explicit-any
911
902
function setOutput(name, value) {
903
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
904
+ if (filePath) {
905
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
906
+ }
912
907
process.stdout.write(os.EOL);
913
- command_1.issueCommand('set-output', { name }, value);
908
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
914
909
}
915
910
exports.setOutput = setOutput;
916
911
/**
@@ -1039,7 +1034,11 @@ exports.group = group;
1039
1034
*/
1040
1035
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1041
1036
function saveState(name, value) {
1042
- command_1.issueCommand('save-state', { name }, value);
1037
+ const filePath = process.env['GITHUB_STATE'] || '';
1038
+ if (filePath) {
1039
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
1040
+ }
1041
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
1043
1042
}
1044
1043
exports.saveState = saveState;
1045
1044
/**
@@ -1105,13 +1104,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
1105
1104
return result;
1106
1105
};
1107
1106
Object.defineProperty(exports, "__esModule", ({ value: true }));
1108
- exports.issueCommand = void 0;
1107
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
1109
1108
// We use any as a valid input type
1110
1109
/* eslint-disable @typescript-eslint/no-explicit-any */
1111
1110
const fs = __importStar(__nccwpck_require__(7147));
1112
1111
const os = __importStar(__nccwpck_require__(2037));
1112
+ const uuid_1 = __nccwpck_require__(5840);
1113
1113
const utils_1 = __nccwpck_require__(5278);
1114
- function issueCommand (command, message) {
1114
+ function issueFileCommand (command, message) {
1115
1115
const filePath = process.env[`GITHUB_${command}`];
1116
1116
if (!filePath) {
1117
1117
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -1123,7 +1123,22 @@ function issueCommand(command, message) {
1123
1123
encoding: 'utf8'
1124
1124
});
1125
1125
}
1126
- exports.issueCommand = issueCommand;
1126
+ exports.issueFileCommand = issueFileCommand;
1127
+ function prepareKeyValueMessage(key, value) {
1128
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
1129
+ const convertedValue = utils_1.toCommandValue(value);
1130
+ // These should realistically never happen, but just in case someone finds a
1131
+ // way to exploit uuid generation let's not allow keys or values that contain
1132
+ // the delimiter.
1133
+ if (key.includes(delimiter)) {
1134
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
1135
+ }
1136
+ if (convertedValue.includes(delimiter)) {
1137
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
1138
+ }
1139
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
1140
+ }
1141
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
1127
1142
//# sourceMappingURL=file-command.js.map
1128
1143
1129
1144
/***/ }),
0 commit comments