@@ -419,7 +419,6 @@ const file_command_1 = __nccwpck_require__(717);
419
419
const utils_1 = __nccwpck_require__ ( 5278 ) ;
420
420
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
421
421
const path = __importStar ( __nccwpck_require__ ( 1017 ) ) ;
422
- const uuid_1 = __nccwpck_require__ ( 8974 ) ;
423
422
const oidc_utils_1 = __nccwpck_require__ ( 8041 ) ;
424
423
/**
425
424
* The code to exit an action
@@ -449,20 +448,9 @@ function exportVariable(name, val) {
449
448
process . env [ name ] = convertedVal ;
450
449
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
451
450
if ( filePath ) {
452
- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
453
- // 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.
454
- if ( name . includes ( delimiter ) ) {
455
- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
456
- }
457
- if ( convertedVal . includes ( delimiter ) ) {
458
- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
459
- }
460
- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
461
- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
462
- }
463
- else {
464
- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
451
+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
465
452
}
453
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
466
454
}
467
455
exports . exportVariable = exportVariable ;
468
456
/**
@@ -480,7 +468,7 @@ exports.setSecret = setSecret;
480
468
function addPath ( inputPath ) {
481
469
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
482
470
if ( filePath ) {
483
- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
471
+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
484
472
}
485
473
else {
486
474
command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -520,7 +508,10 @@ function getMultilineInput(name, options) {
520
508
const inputs = getInput ( name , options )
521
509
. split ( '\n' )
522
510
. filter ( x => x !== '' ) ;
523
- return inputs ;
511
+ if ( options && options . trimWhitespace === false ) {
512
+ return inputs ;
513
+ }
514
+ return inputs . map ( input => input . trim ( ) ) ;
524
515
}
525
516
exports . getMultilineInput = getMultilineInput ;
526
517
/**
@@ -553,8 +544,12 @@ exports.getBooleanInput = getBooleanInput;
553
544
*/
554
545
// eslint-disable-next-line @typescript-eslint/no-explicit-any
555
546
function setOutput ( name , value ) {
547
+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
548
+ if ( filePath ) {
549
+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
550
+ }
556
551
process . stdout . write ( os . EOL ) ;
557
- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
552
+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
558
553
}
559
554
exports . setOutput = setOutput ;
560
555
/**
@@ -683,7 +678,11 @@ exports.group = group;
683
678
*/
684
679
// eslint-disable-next-line @typescript-eslint/no-explicit-any
685
680
function saveState ( name , value ) {
686
- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
681
+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
682
+ if ( filePath ) {
683
+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
684
+ }
685
+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
687
686
}
688
687
exports . saveState = saveState ;
689
688
/**
@@ -749,13 +748,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
749
748
return result ;
750
749
} ;
751
750
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
752
- exports . issueCommand = void 0 ;
751
+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
753
752
// We use any as a valid input type
754
753
/* eslint-disable @typescript-eslint/no-explicit-any */
755
754
const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
756
755
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
756
+ const uuid_1 = __nccwpck_require__ ( 8974 ) ;
757
757
const utils_1 = __nccwpck_require__ ( 5278 ) ;
758
- function issueCommand ( command , message ) {
758
+ function issueFileCommand ( command , message ) {
759
759
const filePath = process . env [ `GITHUB_${ command } ` ] ;
760
760
if ( ! filePath ) {
761
761
throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -767,7 +767,22 @@ function issueCommand(command, message) {
767
767
encoding : 'utf8'
768
768
} ) ;
769
769
}
770
- exports . issueCommand = issueCommand ;
770
+ exports . issueFileCommand = issueFileCommand ;
771
+ function prepareKeyValueMessage ( key , value ) {
772
+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
773
+ const convertedValue = utils_1 . toCommandValue ( value ) ;
774
+ // These should realistically never happen, but just in case someone finds a
775
+ // way to exploit uuid generation let's not allow keys or values that contain
776
+ // the delimiter.
777
+ if ( key . includes ( delimiter ) ) {
778
+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
779
+ }
780
+ if ( convertedValue . includes ( delimiter ) ) {
781
+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
782
+ }
783
+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
784
+ }
785
+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
771
786
//# sourceMappingURL=file-command.js.map
772
787
773
788
/***/ } ) ,
0 commit comments