@@ -380,7 +380,6 @@ const file_command_1 = __nccwpck_require__(717);
380
380
const utils_1 = __nccwpck_require__ ( 5278 ) ;
381
381
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
382
382
const path = __importStar ( __nccwpck_require__ ( 1017 ) ) ;
383
- const uuid_1 = __nccwpck_require__ ( 5840 ) ;
384
383
const oidc_utils_1 = __nccwpck_require__ ( 8041 ) ;
385
384
/**
386
385
* The code to exit an action
@@ -410,20 +409,9 @@ function exportVariable(name, val) {
410
409
process . env [ name ] = convertedVal ;
411
410
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
412
411
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 ) ) ;
426
413
}
414
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
427
415
}
428
416
exports . exportVariable = exportVariable ;
429
417
/**
@@ -441,7 +429,7 @@ exports.setSecret = setSecret;
441
429
function addPath ( inputPath ) {
442
430
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
443
431
if ( filePath ) {
444
- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
432
+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
445
433
}
446
434
else {
447
435
command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -481,7 +469,10 @@ function getMultilineInput(name, options) {
481
469
const inputs = getInput ( name , options )
482
470
. split ( '\n' )
483
471
. filter ( x => x !== '' ) ;
484
- return inputs ;
472
+ if ( options && options . trimWhitespace === false ) {
473
+ return inputs ;
474
+ }
475
+ return inputs . map ( input => input . trim ( ) ) ;
485
476
}
486
477
exports . getMultilineInput = getMultilineInput ;
487
478
/**
@@ -514,8 +505,12 @@ exports.getBooleanInput = getBooleanInput;
514
505
*/
515
506
// eslint-disable-next-line @typescript-eslint/no-explicit-any
516
507
function 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
+ }
517
512
process . stdout . write ( os . EOL ) ;
518
- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
513
+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
519
514
}
520
515
exports . setOutput = setOutput ;
521
516
/**
@@ -644,7 +639,11 @@ exports.group = group;
644
639
*/
645
640
// eslint-disable-next-line @typescript-eslint/no-explicit-any
646
641
function 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 ) ) ;
648
647
}
649
648
exports . saveState = saveState ;
650
649
/**
@@ -710,13 +709,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
710
709
return result ;
711
710
} ;
712
711
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
713
- exports . issueCommand = void 0 ;
712
+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
714
713
// We use any as a valid input type
715
714
/* eslint-disable @typescript-eslint/no-explicit-any */
716
715
const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
717
716
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
717
+ const uuid_1 = __nccwpck_require__ ( 5840 ) ;
718
718
const utils_1 = __nccwpck_require__ ( 5278 ) ;
719
- function issueCommand ( command , message ) {
719
+ function issueFileCommand ( command , message ) {
720
720
const filePath = process . env [ `GITHUB_${ command } ` ] ;
721
721
if ( ! filePath ) {
722
722
throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -728,7 +728,22 @@ function issueCommand(command, message) {
728
728
encoding : 'utf8'
729
729
} ) ;
730
730
}
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 ;
732
747
//# sourceMappingURL=file-command.js.map
733
748
734
749
/***/ } ) ,
0 commit comments