Skip to content

Commit 0b60d8c

Browse files
authored
chore: Update dist (#532)
1 parent 50eedb0 commit 0b60d8c

File tree

2 files changed

+228
-96
lines changed

2 files changed

+228
-96
lines changed

dist/cleanup/index.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
237237
return result;
238238
};
239239
Object.defineProperty(exports, "__esModule", { value: true });
240-
exports.issueCommand = void 0;
240+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
241241
// We use any as a valid input type
242242
/* eslint-disable @typescript-eslint/no-explicit-any */
243243
const fs = __importStar(__webpack_require__(747));
244244
const os = __importStar(__webpack_require__(87));
245+
const uuid_1 = __webpack_require__(25);
245246
const utils_1 = __webpack_require__(82);
246-
function issueCommand(command, message) {
247+
function issueFileCommand(command, message) {
247248
const filePath = process.env[`GITHUB_${command}`];
248249
if (!filePath) {
249250
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -255,7 +256,22 @@ function issueCommand(command, message) {
255256
encoding: 'utf8'
256257
});
257258
}
258-
exports.issueCommand = issueCommand;
259+
exports.issueFileCommand = issueFileCommand;
260+
function prepareKeyValueMessage(key, value) {
261+
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
262+
const convertedValue = utils_1.toCommandValue(value);
263+
// These should realistically never happen, but just in case someone finds a
264+
// way to exploit uuid generation let's not allow keys or values that contain
265+
// the delimiter.
266+
if (key.includes(delimiter)) {
267+
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
268+
}
269+
if (convertedValue.includes(delimiter)) {
270+
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
271+
}
272+
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
273+
}
274+
exports.prepareKeyValueMessage = prepareKeyValueMessage;
259275
//# sourceMappingURL=file-command.js.map
260276

261277
/***/ }),
@@ -1662,7 +1678,6 @@ const file_command_1 = __webpack_require__(102);
16621678
const utils_1 = __webpack_require__(82);
16631679
const os = __importStar(__webpack_require__(87));
16641680
const path = __importStar(__webpack_require__(622));
1665-
const uuid_1 = __webpack_require__(25);
16661681
const oidc_utils_1 = __webpack_require__(742);
16671682
/**
16681683
* The code to exit an action
@@ -1692,20 +1707,9 @@ function exportVariable(name, val) {
16921707
process.env[name] = convertedVal;
16931708
const filePath = process.env['GITHUB_ENV'] || '';
16941709
if (filePath) {
1695-
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
1696-
// 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.
1697-
if (name.includes(delimiter)) {
1698-
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
1699-
}
1700-
if (convertedVal.includes(delimiter)) {
1701-
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
1702-
}
1703-
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
1704-
file_command_1.issueCommand('ENV', commandValue);
1705-
}
1706-
else {
1707-
command_1.issueCommand('set-env', { name }, convertedVal);
1710+
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
17081711
}
1712+
command_1.issueCommand('set-env', { name }, convertedVal);
17091713
}
17101714
exports.exportVariable = exportVariable;
17111715
/**
@@ -1723,7 +1727,7 @@ exports.setSecret = setSecret;
17231727
function addPath(inputPath) {
17241728
const filePath = process.env['GITHUB_PATH'] || '';
17251729
if (filePath) {
1726-
file_command_1.issueCommand('PATH', inputPath);
1730+
file_command_1.issueFileCommand('PATH', inputPath);
17271731
}
17281732
else {
17291733
command_1.issueCommand('add-path', {}, inputPath);
@@ -1763,7 +1767,10 @@ function getMultilineInput(name, options) {
17631767
const inputs = getInput(name, options)
17641768
.split('\n')
17651769
.filter(x => x !== '');
1766-
return inputs;
1770+
if (options && options.trimWhitespace === false) {
1771+
return inputs;
1772+
}
1773+
return inputs.map(input => input.trim());
17671774
}
17681775
exports.getMultilineInput = getMultilineInput;
17691776
/**
@@ -1796,8 +1803,12 @@ exports.getBooleanInput = getBooleanInput;
17961803
*/
17971804
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17981805
function setOutput(name, value) {
1806+
const filePath = process.env['GITHUB_OUTPUT'] || '';
1807+
if (filePath) {
1808+
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
1809+
}
17991810
process.stdout.write(os.EOL);
1800-
command_1.issueCommand('set-output', { name }, value);
1811+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
18011812
}
18021813
exports.setOutput = setOutput;
18031814
/**
@@ -1926,7 +1937,11 @@ exports.group = group;
19261937
*/
19271938
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19281939
function saveState(name, value) {
1929-
command_1.issueCommand('save-state', { name }, value);
1940+
const filePath = process.env['GITHUB_STATE'] || '';
1941+
if (filePath) {
1942+
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
1943+
}
1944+
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
19301945
}
19311946
exports.saveState = saveState;
19321947
/**

0 commit comments

Comments
 (0)