@@ -237,13 +237,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
237
237
return result ;
238
238
} ;
239
239
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
240
- exports . issueCommand = void 0 ;
240
+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
241
241
// We use any as a valid input type
242
242
/* eslint-disable @typescript-eslint/no-explicit-any */
243
243
const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
244
244
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
245
+ const uuid_1 = __webpack_require__ ( 25 ) ;
245
246
const utils_1 = __webpack_require__ ( 82 ) ;
246
- function issueCommand ( command , message ) {
247
+ function issueFileCommand ( command , message ) {
247
248
const filePath = process . env [ `GITHUB_${ command } ` ] ;
248
249
if ( ! filePath ) {
249
250
throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -255,7 +256,22 @@ function issueCommand(command, message) {
255
256
encoding : 'utf8'
256
257
} ) ;
257
258
}
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 ;
259
275
//# sourceMappingURL=file-command.js.map
260
276
261
277
/***/ } ) ,
@@ -1662,7 +1678,6 @@ const file_command_1 = __webpack_require__(102);
1662
1678
const utils_1 = __webpack_require__ ( 82 ) ;
1663
1679
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1664
1680
const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1665
- const uuid_1 = __webpack_require__ ( 25 ) ;
1666
1681
const oidc_utils_1 = __webpack_require__ ( 742 ) ;
1667
1682
/**
1668
1683
* The code to exit an action
@@ -1692,20 +1707,9 @@ function exportVariable(name, val) {
1692
1707
process . env [ name ] = convertedVal ;
1693
1708
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
1694
1709
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 ) ) ;
1708
1711
}
1712
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
1709
1713
}
1710
1714
exports . exportVariable = exportVariable ;
1711
1715
/**
@@ -1723,7 +1727,7 @@ exports.setSecret = setSecret;
1723
1727
function addPath ( inputPath ) {
1724
1728
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
1725
1729
if ( filePath ) {
1726
- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
1730
+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
1727
1731
}
1728
1732
else {
1729
1733
command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -1763,7 +1767,10 @@ function getMultilineInput(name, options) {
1763
1767
const inputs = getInput ( name , options )
1764
1768
. split ( '\n' )
1765
1769
. filter ( x => x !== '' ) ;
1766
- return inputs ;
1770
+ if ( options && options . trimWhitespace === false ) {
1771
+ return inputs ;
1772
+ }
1773
+ return inputs . map ( input => input . trim ( ) ) ;
1767
1774
}
1768
1775
exports . getMultilineInput = getMultilineInput ;
1769
1776
/**
@@ -1796,8 +1803,12 @@ exports.getBooleanInput = getBooleanInput;
1796
1803
*/
1797
1804
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1798
1805
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
+ }
1799
1810
process . stdout . write ( os . EOL ) ;
1800
- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
1811
+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
1801
1812
}
1802
1813
exports . setOutput = setOutput ;
1803
1814
/**
@@ -1926,7 +1937,11 @@ exports.group = group;
1926
1937
*/
1927
1938
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1928
1939
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 ) ) ;
1930
1945
}
1931
1946
exports . saveState = saveState ;
1932
1947
/**
0 commit comments