Skip to content

Commit b9e5093

Browse files
authored
build: update distribution
1 parent eebc680 commit b9e5093

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

dist/index.js

+36-21
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,6 @@ const file_command_1 = __nccwpck_require__(717);
775775
const utils_1 = __nccwpck_require__(5278);
776776
const os = __importStar(__nccwpck_require__(2037));
777777
const path = __importStar(__nccwpck_require__(1017));
778-
const uuid_1 = __nccwpck_require__(5840);
779778
const oidc_utils_1 = __nccwpck_require__(8041);
780779
/**
781780
* The code to exit an action
@@ -805,20 +804,9 @@ function exportVariable(name, val) {
805804
process.env[name] = convertedVal;
806805
const filePath = process.env['GITHUB_ENV'] || '';
807806
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));
821808
}
809+
command_1.issueCommand('set-env', { name }, convertedVal);
822810
}
823811
exports.exportVariable = exportVariable;
824812
/**
@@ -836,7 +824,7 @@ exports.setSecret = setSecret;
836824
function addPath(inputPath) {
837825
const filePath = process.env['GITHUB_PATH'] || '';
838826
if (filePath) {
839-
file_command_1.issueCommand('PATH', inputPath);
827+
file_command_1.issueFileCommand('PATH', inputPath);
840828
}
841829
else {
842830
command_1.issueCommand('add-path', {}, inputPath);
@@ -876,7 +864,10 @@ function getMultilineInput(name, options) {
876864
const inputs = getInput(name, options)
877865
.split('\n')
878866
.filter(x => x !== '');
879-
return inputs;
867+
if (options && options.trimWhitespace === false) {
868+
return inputs;
869+
}
870+
return inputs.map(input => input.trim());
880871
}
881872
exports.getMultilineInput = getMultilineInput;
882873
/**
@@ -909,8 +900,12 @@ exports.getBooleanInput = getBooleanInput;
909900
*/
910901
// eslint-disable-next-line @typescript-eslint/no-explicit-any
911902
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+
}
912907
process.stdout.write(os.EOL);
913-
command_1.issueCommand('set-output', { name }, value);
908+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
914909
}
915910
exports.setOutput = setOutput;
916911
/**
@@ -1039,7 +1034,11 @@ exports.group = group;
10391034
*/
10401035
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10411036
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));
10431042
}
10441043
exports.saveState = saveState;
10451044
/**
@@ -1105,13 +1104,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
11051104
return result;
11061105
};
11071106
Object.defineProperty(exports, "__esModule", ({ value: true }));
1108-
exports.issueCommand = void 0;
1107+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
11091108
// We use any as a valid input type
11101109
/* eslint-disable @typescript-eslint/no-explicit-any */
11111110
const fs = __importStar(__nccwpck_require__(7147));
11121111
const os = __importStar(__nccwpck_require__(2037));
1112+
const uuid_1 = __nccwpck_require__(5840);
11131113
const utils_1 = __nccwpck_require__(5278);
1114-
function issueCommand(command, message) {
1114+
function issueFileCommand(command, message) {
11151115
const filePath = process.env[`GITHUB_${command}`];
11161116
if (!filePath) {
11171117
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -1123,7 +1123,22 @@ function issueCommand(command, message) {
11231123
encoding: 'utf8'
11241124
});
11251125
}
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;
11271142
//# sourceMappingURL=file-command.js.map
11281143

11291144
/***/ }),

0 commit comments

Comments
 (0)