@@ -470,7 +470,6 @@ const file_command_1 = __nccwpck_require__(717);
470
470
const utils_1 = __nccwpck_require__ ( 5278 ) ;
471
471
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
472
472
const path = __importStar ( __nccwpck_require__ ( 1017 ) ) ;
473
- const uuid_1 = __nccwpck_require__ ( 8974 ) ;
474
473
const oidc_utils_1 = __nccwpck_require__ ( 8041 ) ;
475
474
/**
476
475
* The code to exit an action
@@ -500,20 +499,9 @@ function exportVariable(name, val) {
500
499
process . env [ name ] = convertedVal ;
501
500
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
502
501
if ( filePath ) {
503
- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
504
- // 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.
505
- if ( name . includes ( delimiter ) ) {
506
- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
507
- }
508
- if ( convertedVal . includes ( delimiter ) ) {
509
- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
510
- }
511
- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
512
- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
513
- }
514
- else {
515
- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
502
+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
516
503
}
504
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
517
505
}
518
506
exports . exportVariable = exportVariable ;
519
507
/**
@@ -531,7 +519,7 @@ exports.setSecret = setSecret;
531
519
function addPath ( inputPath ) {
532
520
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
533
521
if ( filePath ) {
534
- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
522
+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
535
523
}
536
524
else {
537
525
command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -571,7 +559,10 @@ function getMultilineInput(name, options) {
571
559
const inputs = getInput ( name , options )
572
560
. split ( '\n' )
573
561
. filter ( x => x !== '' ) ;
574
- return inputs ;
562
+ if ( options && options . trimWhitespace === false ) {
563
+ return inputs ;
564
+ }
565
+ return inputs . map ( input => input . trim ( ) ) ;
575
566
}
576
567
exports . getMultilineInput = getMultilineInput ;
577
568
/**
@@ -604,8 +595,12 @@ exports.getBooleanInput = getBooleanInput;
604
595
*/
605
596
// eslint-disable-next-line @typescript-eslint/no-explicit-any
606
597
function setOutput ( name , value ) {
598
+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
599
+ if ( filePath ) {
600
+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
601
+ }
607
602
process . stdout . write ( os . EOL ) ;
608
- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
603
+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
609
604
}
610
605
exports . setOutput = setOutput ;
611
606
/**
@@ -734,7 +729,11 @@ exports.group = group;
734
729
*/
735
730
// eslint-disable-next-line @typescript-eslint/no-explicit-any
736
731
function saveState ( name , value ) {
737
- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
732
+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
733
+ if ( filePath ) {
734
+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
735
+ }
736
+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
738
737
}
739
738
exports . saveState = saveState ;
740
739
/**
@@ -800,13 +799,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
800
799
return result ;
801
800
} ;
802
801
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
803
- exports . issueCommand = void 0 ;
802
+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
804
803
// We use any as a valid input type
805
804
/* eslint-disable @typescript-eslint/no-explicit-any */
806
805
const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
807
806
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
807
+ const uuid_1 = __nccwpck_require__ ( 8974 ) ;
808
808
const utils_1 = __nccwpck_require__ ( 5278 ) ;
809
- function issueCommand ( command , message ) {
809
+ function issueFileCommand ( command , message ) {
810
810
const filePath = process . env [ `GITHUB_${ command } ` ] ;
811
811
if ( ! filePath ) {
812
812
throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -818,7 +818,22 @@ function issueCommand(command, message) {
818
818
encoding : 'utf8'
819
819
} ) ;
820
820
}
821
- exports . issueCommand = issueCommand ;
821
+ exports . issueFileCommand = issueFileCommand ;
822
+ function prepareKeyValueMessage ( key , value ) {
823
+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
824
+ const convertedValue = utils_1 . toCommandValue ( value ) ;
825
+ // These should realistically never happen, but just in case someone finds a
826
+ // way to exploit uuid generation let's not allow keys or values that contain
827
+ // the delimiter.
828
+ if ( key . includes ( delimiter ) ) {
829
+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
830
+ }
831
+ if ( convertedValue . includes ( delimiter ) ) {
832
+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
833
+ }
834
+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
835
+ }
836
+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
822
837
//# sourceMappingURL=file-command.js.map
823
838
824
839
/***/ } ) ,
0 commit comments