@@ -380,7 +380,6 @@ const file_command_1 = __nccwpck_require__(717);
380380const utils_1 = __nccwpck_require__ ( 5278 ) ;
381381const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
382382const path = __importStar ( __nccwpck_require__ ( 1017 ) ) ;
383- const uuid_1 = __nccwpck_require__ ( 5840 ) ;
384383const oidc_utils_1 = __nccwpck_require__ ( 8041 ) ;
385384/**
386385 * The code to exit an action
@@ -410,20 +409,9 @@ function exportVariable(name, val) {
410409 process . env [ name ] = convertedVal ;
411410 const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
412411 if ( filePath ) {
413- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
414- // 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.
415- if ( name . includes ( delimiter ) ) {
416- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
417- }
418- if ( convertedVal . includes ( delimiter ) ) {
419- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
420- }
421- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
422- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
423- }
424- else {
425- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
412+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
426413 }
414+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
427415}
428416exports . exportVariable = exportVariable ;
429417/**
@@ -441,7 +429,7 @@ exports.setSecret = setSecret;
441429function addPath ( inputPath ) {
442430 const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
443431 if ( filePath ) {
444- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
432+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
445433 }
446434 else {
447435 command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -481,7 +469,10 @@ function getMultilineInput(name, options) {
481469 const inputs = getInput ( name , options )
482470 . split ( '\n' )
483471 . filter ( x => x !== '' ) ;
484- return inputs ;
472+ if ( options && options . trimWhitespace === false ) {
473+ return inputs ;
474+ }
475+ return inputs . map ( input => input . trim ( ) ) ;
485476}
486477exports . getMultilineInput = getMultilineInput ;
487478/**
@@ -514,8 +505,12 @@ exports.getBooleanInput = getBooleanInput;
514505 */
515506// eslint-disable-next-line @typescript-eslint/no-explicit-any
516507function setOutput ( name , value ) {
508+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
509+ if ( filePath ) {
510+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
511+ }
517512 process . stdout . write ( os . EOL ) ;
518- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
513+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
519514}
520515exports . setOutput = setOutput ;
521516/**
@@ -644,7 +639,11 @@ exports.group = group;
644639 */
645640// eslint-disable-next-line @typescript-eslint/no-explicit-any
646641function saveState ( name , value ) {
647- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
642+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
643+ if ( filePath ) {
644+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
645+ }
646+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
648647}
649648exports . saveState = saveState ;
650649/**
@@ -710,13 +709,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
710709 return result ;
711710} ;
712711Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
713- exports . issueCommand = void 0 ;
712+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
714713// We use any as a valid input type
715714/* eslint-disable @typescript-eslint/no-explicit-any */
716715const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
717716const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
717+ const uuid_1 = __nccwpck_require__ ( 5840 ) ;
718718const utils_1 = __nccwpck_require__ ( 5278 ) ;
719- function issueCommand ( command , message ) {
719+ function issueFileCommand ( command , message ) {
720720 const filePath = process . env [ `GITHUB_${ command } ` ] ;
721721 if ( ! filePath ) {
722722 throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -728,7 +728,22 @@ function issueCommand(command, message) {
728728 encoding : 'utf8'
729729 } ) ;
730730}
731- exports . issueCommand = issueCommand ;
731+ exports . issueFileCommand = issueFileCommand ;
732+ function prepareKeyValueMessage ( key , value ) {
733+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
734+ const convertedValue = utils_1 . toCommandValue ( value ) ;
735+ // These should realistically never happen, but just in case someone finds a
736+ // way to exploit uuid generation let's not allow keys or values that contain
737+ // the delimiter.
738+ if ( key . includes ( delimiter ) ) {
739+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
740+ }
741+ if ( convertedValue . includes ( delimiter ) ) {
742+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
743+ }
744+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
745+ }
746+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
732747//# sourceMappingURL=file-command.js.map
733748
734749/***/ } ) ,
0 commit comments