@@ -1458,7 +1458,6 @@ const file_command_1 = __nccwpck_require__(717);
1458
1458
const utils_1 = __nccwpck_require__(5278);
1459
1459
const os = __importStar(__nccwpck_require__(2037));
1460
1460
const path = __importStar(__nccwpck_require__(1017));
1461
- const uuid_1 = __nccwpck_require__(5840);
1462
1461
const oidc_utils_1 = __nccwpck_require__(8041);
1463
1462
/**
1464
1463
* The code to exit an action
@@ -1488,20 +1487,9 @@ function exportVariable(name, val) {
1488
1487
process.env[name] = convertedVal;
1489
1488
const filePath = process.env['GITHUB_ENV'] || '';
1490
1489
if (filePath) {
1491
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
1492
- // 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.
1493
- if (name.includes(delimiter)) {
1494
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
1495
- }
1496
- if (convertedVal.includes(delimiter)) {
1497
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
1498
- }
1499
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
1500
- file_command_1.issueCommand('ENV', commandValue);
1501
- }
1502
- else {
1503
- command_1.issueCommand('set-env', { name }, convertedVal);
1490
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
1504
1491
}
1492
+ command_1.issueCommand('set-env', { name }, convertedVal);
1505
1493
}
1506
1494
exports.exportVariable = exportVariable;
1507
1495
/**
@@ -1519,7 +1507,7 @@ exports.setSecret = setSecret;
1519
1507
function addPath(inputPath) {
1520
1508
const filePath = process.env['GITHUB_PATH'] || '';
1521
1509
if (filePath) {
1522
- file_command_1.issueCommand ('PATH', inputPath);
1510
+ file_command_1.issueFileCommand ('PATH', inputPath);
1523
1511
}
1524
1512
else {
1525
1513
command_1.issueCommand('add-path', {}, inputPath);
@@ -1559,7 +1547,10 @@ function getMultilineInput(name, options) {
1559
1547
const inputs = getInput(name, options)
1560
1548
.split('\n')
1561
1549
.filter(x => x !== '');
1562
- return inputs;
1550
+ if (options && options.trimWhitespace === false) {
1551
+ return inputs;
1552
+ }
1553
+ return inputs.map(input => input.trim());
1563
1554
}
1564
1555
exports.getMultilineInput = getMultilineInput;
1565
1556
/**
@@ -1592,8 +1583,12 @@ exports.getBooleanInput = getBooleanInput;
1592
1583
*/
1593
1584
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1594
1585
function setOutput(name, value) {
1586
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
1587
+ if (filePath) {
1588
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
1589
+ }
1595
1590
process.stdout.write(os.EOL);
1596
- command_1.issueCommand('set-output', { name }, value);
1591
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
1597
1592
}
1598
1593
exports.setOutput = setOutput;
1599
1594
/**
@@ -1722,7 +1717,11 @@ exports.group = group;
1722
1717
*/
1723
1718
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1724
1719
function saveState(name, value) {
1725
- command_1.issueCommand('save-state', { name }, value);
1720
+ const filePath = process.env['G
8000
ITHUB_STATE'] || '';
1721
+ if (filePath) {
1722
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
1723
+ }
1724
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
1726
1725
}
1727
1726
exports.saveState = saveState;
1728
1727
/**
@@ -1788,13 +1787,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
1788
1787
return result;
1789
1788
};
1790
1789
Object.defineProperty(exports, "__esModule", ({ value: true }));
1791
- exports.issueCommand = void 0;
1790
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
1792
1791
// We use any as a valid input type
1793
1792
/* eslint-disable @typescript-eslint/no-explicit-any */
1794
1793
const fs = __importStar(__nccwpck_require__(7147));
1795
1794
const os = __importStar(__nccwpck_require__(2037));
1795
+ const uuid_1 = __nccwpck_require__(5840);
1796
1796
const utils_1 = __nccwpck_require__(5278);
1797
- function issueCommand (command, message) {
1797
+ function issueFileCommand (command, message) {
1798
1798
const filePath = process.env[`GITHUB_${command}`];
1799
1799
if (!filePath) {
1800
1800
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -1806,7 +1806,22 @@ function issueCommand(command, message) {
1806
1806
encoding: 'utf8'
1807
1807
});
1808
1808
}
1809
- exports.issueCommand = issueCommand;
1809
+ exports.issueFileCommand = issueFileCommand;
1810
+ function prepareKeyValueMessage(key, value) {
1811
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
1812
+ const convertedValue = utils_1.toCommandValue(value);
1813
+ // These should realistically never happen, but just in case someone finds a
1814
+ // way to exploit uuid generation let's not allow keys or values that contain
1815
+ // the delimiter.
1816
+ if (key.includes(delimiter)) {
1817
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
1818
+ }
1819
+ if (convertedValue.includes(delimiter)) {
1820
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
1821
+ }
1822
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
1823
+ }
1824
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
1810
1825
//# sourceMappingURL=file-command.js.map
1811
1826
1812
1827
/***/ }),
0 commit comments