@@ -815,7 +815,6 @@ const file_command_1 = __nccwpck_require__(717);
815815const utils_1 = __nccwpck_require__ ( 278 ) ;
816816const os = __importStar ( __nccwpck_require__ ( 37 ) ) ;
817817const path = __importStar ( __nccwpck_require__ ( 17 ) ) ;
818- const uuid_1 = __nccwpck_require__ ( 840 ) ;
819818const oidc_utils_1 = __nccwpck_require__ ( 41 ) ;
820819/**
821820 * The code to exit an action
@@ -845,20 +844,9 @@ function exportVariable(name, val) {
845844 process . env [ name ] = convertedVal ;
846845 const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
847846 if ( filePath ) {
848- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
849- // 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.
850- if ( name . includes ( delimiter ) ) {
851- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
852- }
853- if ( convertedVal . includes ( delimiter ) ) {
854- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
855- }
856- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
857- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
858- }
859- else {
860- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
847+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
861848 }
849+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
862850}
863851exports . exportVariable = exportVariable ;
864852/**
@@ -876,7 +864,7 @@ exports.setSecret = setSecret;
876864function addPath ( inputPath ) {
877865 const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
878866 if ( filePath ) {
879- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
867+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
880868 }
881869 else {
882870 command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -916,7 +904,10 @@ function getMultilineInput(name, options) {
916904 const inputs = getInput ( name , options )
917905 . split ( '\n' )
918906 . filter ( x => x !== '' ) ;
919- return inputs ;
907+ if ( options && options . trimWhitespace === false ) {
908+ return inputs ;
909+ }
910+ return inputs . map ( input => input . trim ( ) ) ;
920911}
921912exports . getMultilineInput = getMultilineInput ;
922913/**
@@ -949,8 +940,12 @@ exports.getBooleanInput = getBooleanInput;
949940 */
950941// eslint-disable-next-line @typescript-eslint/no-explicit-any
951942function setOutput ( name , value ) {
943+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
944+ if ( filePath ) {
945+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
946+ }
952947 process . stdout . write ( os . EOL ) ;
953- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
948+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
954949}
955950exports . setOutput = setOutput ;
956951/**
@@ -1079,7 +1074,11 @@ exports.group = group;
10791074 */
10801075// eslint-disable-next-line @typescript-eslint/no-explicit-any
10811076function saveState ( name , value ) {
1082- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
1077+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
1078+ if ( filePath ) {
1079+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
1080+ }
1081+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
10831082}
10841083exports . saveState = saveState ;
10851084/**
@@ -1145,13 +1144,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
11451144 return result ;
11461145} ;
11471146Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
1148- exports . issueCommand = void 0 ;
1147+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
11491148// We use any as a valid input type
11501149/* eslint-disable @typescript-eslint/no-explicit-any */
11511150const fs = __importStar ( __nccwpck_require__ ( 147 ) ) ;
11521151const os = __importStar ( __nccwpck_require__ ( 37 ) ) ;
1152+ const uuid_1 = __nccwpck_require__ ( 840 ) ;
11531153const utils_1 = __nccwpck_require__ ( 278 ) ;
1154- function issueCommand ( command , message ) {
1154+ function issueFileCommand ( command , message ) {
11551155 const filePath = process . env [ `GITHUB_${ command } ` ] ;
11561156 if ( ! filePath ) {
11571157 throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -1163,7 +1163,22 @@ function issueCommand(command, message) {
11631163 encoding : 'utf8'
11641164 } ) ;
11651165}
1166- exports . issueCommand = issueCommand ;
1166+ exports . issueFileCommand = issueFileCommand ;
1167+ function prepareKeyValueMessage ( key , value ) {
1168+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
1169+ const convertedValue = utils_1 . toCommandValue ( value ) ;
1170+ // These should realistically never happen, but just in case someone finds a
1171+ // way to exploit uuid generation let's not allow keys or values that contain
1172+ // the delimiter.
1173+ if ( key . includes ( delimiter ) ) {
1174+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
1175+ }
1176+ if ( convertedValue . includes ( delimiter ) ) {
1177+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
1178+ }
1179+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
1180+ }
1181+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
11671182//# sourceMappingURL=file-command.js.map
11681183
11691184/***/ } ) ,
0 commit comments