@@ -298,13 +298,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
298298 return result ;
299299} ;
300300Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
301- exports . issueCommand = void 0 ;
301+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
302302// We use any as a valid input type
303303/* eslint-disable @typescript-eslint/no-explicit-any */
304304const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
305305const os = __importStar ( __webpack_require__ ( 87 ) ) ;
306+ const uuid_1 = __webpack_require__ ( 62 ) ;
306307const utils_1 = __webpack_require__ ( 82 ) ;
307- function issueCommand ( command , message ) {
308+ function issueFileCommand ( command , message ) {
308309 const filePath = process . env [ `GITHUB_${ command } ` ] ;
309310 if ( ! filePath ) {
310311 throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -316,7 +317,22 @@ function issueCommand(command, message) {
316317 encoding : 'utf8'
317318 } ) ;
318319}
319- exports . issueCommand = issueCommand ;
320+ exports . issueFileCommand = issueFileCommand ;
321+ function prepareKeyValueMessage ( key , value ) {
322+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
323+ const convertedValue = utils_1 . toCommandValue ( value ) ;
324+ // These should realistically never happen, but just in case someone finds a
325+ // way to exploit uuid generation let's not allow keys or values that contain
326+ // the delimiter.
327+ if ( key . includes ( delimiter ) ) {
328+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
329+ }
330+ if ( convertedValue . includes ( delimiter ) ) {
331+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
332+ }
333+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
334+ }
335+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
320336//# sourceMappingURL=file-command.js.map
321337
322338/***/ } ) ,
@@ -1671,7 +1687,6 @@ const file_command_1 = __webpack_require__(102);
16711687const utils_1 = __webpack_require__ ( 82 ) ;
16721688const os = __importStar ( __webpack_require__ ( 87 ) ) ;
16731689const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1674- const uuid_1 = __webpack_require__ ( 62 ) ;
16751690const oidc_utils_1 = __webpack_require__ ( 742 ) ;
16761691/**
16771692 * The code to exit an action
@@ -1701,20 +1716,9 @@ function exportVariable(name, val) {
17011716 process . env [ name ] = convertedVal ;
17021717 const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
17031718 if ( filePath ) {
1704- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
1705- // 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.
1706- if ( name . includes ( delimiter ) ) {
1707- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
1708- }
1709- if ( convertedVal . includes ( delimiter ) ) {
1710- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
1711- }
1712- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
1713- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
1714- }
1715- else {
1716- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
1719+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
17171720 }
1721+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
17181722}
17191723exports . exportVariable = exportVariable ;
17201724/**
@@ -1732,7 +1736,7 @@ exports.setSecret = setSecret;
17321736function addPath ( inputPath ) {
17331737 const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
17341738 if ( filePath ) {
1735- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
1739+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
17361740 }
17371741 else {
17381742 command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -1772,7 +1776,10 @@ function getMultilineInput(name, options) {
17721776 const inputs = getInput ( name , options )
17731777 . split ( '\n' )
17741778 . filter ( x => x !== '' ) ;
1775- return inputs ;
1779+ if ( options && options . trimWhitespace === false ) {
1780+ return inputs ;
1781+ }
1782+ return inputs . map ( input => input . trim ( ) ) ;
17761783}
17771784exports . getMultilineInput = getMultilineInput ;
17781785/**
@@ -1805,8 +1812,12 @@ exports.getBooleanInput = getBooleanInput;
18051812 */
18061813// eslint-disable-next-line @typescript-eslint/no-explicit-any
18071814function setOutput ( name , value ) {
1815+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
1816+ if ( filePath ) {
1817+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
1818+ }
18081819 process . stdout . write ( os . EOL ) ;
1809- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
1820+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
18101821}
18111822exports . setOutput = setOutput ;
18121823/**
@@ -1935,7 +1946,11 @@ exports.group = group;
19351946 */
19361947// eslint-disable-next-line @typescript-eslint/no-explicit-any
19371948function saveState ( name , value ) {
1938- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
1949+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
1950+ if ( filePath ) {
1951+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
1952+ }
1953+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
19391954}
19401955exports . saveState = saveState ;
19411956/**
0 commit comments