@@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(352);
140140const utils_1 = __nccwpck_require__ ( 245 ) ;
141141const os = __importStar ( __nccwpck_require__ ( 37 ) ) ;
142142const path = __importStar ( __nccwpck_require__ ( 17 ) ) ;
143- const uuid_1 = __nccwpck_require__ ( 321 ) ;
144143const oidc_utils_1 = __nccwpck_require__ ( 457 ) ;
145144/**
146145 * The code to exit an action
@@ -170,20 +169,9 @@ function exportVariable(name, val) {
170169 process . env [ name ] = convertedVal ;
171170 const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
172171 if ( filePath ) {
173- const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
174- // 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.
175- if ( name . includes ( delimiter ) ) {
176- throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
177- }
178- if ( convertedVal . includes ( delimiter ) ) {
179- throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
180- }
181- const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
182- file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
183- }
184- else {
185- command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
172+ return file_command_1 . issueFileCommand ( 'ENV' , file_command_1 . prepareKeyValueMessage ( name , val ) ) ;
186173 }
174+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
187175}
188176exports . exportVariable = exportVariable ;
189177/**
@@ -201,7 +189,7 @@ exports.setSecret = setSecret;
201189function addPath ( inputPath ) {
202190 const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
203191 if ( filePath ) {
204- file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
192+ file_command_1 . issueFileCommand ( 'PATH' , inputPath ) ;
205193 }
206194 else {
207195 command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
@@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
241229 const inputs = getInput ( name , options )
242230 . split ( '\n' )
243231 . filter ( x => x !== '' ) ;
244- return inputs ;
232+ if ( options && options . trimWhitespace === false ) {
233+ return inputs ;
234+ }
235+ return inputs . map ( input => input . trim ( ) ) ;
245236}
246237exports . getMultilineInput = getMultilineInput ;
247238/**
@@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
274265 */
275266// eslint-disable-next-line @typescript-eslint/no-explicit-any
276267function setOutput ( name , value ) {
268+ const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
269+ if ( filePath ) {
270+ return file_command_1 . issueFileCommand ( 'OUTPUT' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
271+ }
277272 process . stdout . write ( os . EOL ) ;
278- command_1 . issueCommand ( 'set-output' , { name } , value ) ;
273+ command_1 . issueCommand ( 'set-output' , { name } , utils_1 . toCommandValue ( value ) ) ;
279274}
280275exports . setOutput = setOutput ;
281276/**
@@ -404,7 +399,11 @@ exports.group = group;
404399 */
405400// eslint-disable-next-line @typescript-eslint/no-explicit-any
406401function saveState ( name , value ) {
407- command_1 . issueCommand ( 'save-state' , { name } , value ) ;
402+ const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
403+ if ( filePath ) {
404+ return file_command_1 . issueFileCommand ( 'STATE' , file_command_1 . prepareKeyValueMessage ( name , value ) ) ;
405+ }
406+ command_1 . issueCommand ( 'save-state' , { name } , utils_1 . toCommandValue ( value ) ) ;
408407}
409408exports . saveState = saveState ;
410409/**
@@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
470469 return result ;
471470} ;
472471Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
473- exports . issueCommand = void 0 ;
472+ exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
474473// We use any as a valid input type
475474/* eslint-disable @typescript-eslint/no-explicit-any */
476475const fs = __importStar ( __nccwpck_require__ ( 147 ) ) ;
477476const os = __importStar ( __nccwpck_require__ ( 37 ) ) ;
477+ const uuid_1 = __nccwpck_require__ ( 321 ) ;
478478const utils_1 = __nccwpck_require__ ( 245 ) ;
479- function issueCommand ( command , message ) {
479+ function issueFileCommand ( command , message ) {
480480 const filePath = process . env [ `GITHUB_${ command } ` ] ;
481481 if ( ! filePath ) {
482482 throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
@@ -488,7 +488,22 @@ function issueCommand(command, message) {
488488 encoding : 'utf8'
489489 } ) ;
490490}
491- exports . issueCommand = issueCommand ;
491+ exports . issueFileCommand = issueFileCommand ;
492+ function prepareKeyValueMessage ( key , value ) {
493+ const delimiter = `ghadelimiter_${ uuid_1 . v4 ( ) } ` ;
494+ const convertedValue = utils_1 . toCommandValue ( value ) ;
495+ // These should realistically never happen, but just in case someone finds a
496+ // way to exploit uuid generation let's not allow keys or values that contain
497+ // the delimiter.
498+ if ( key . includes ( delimiter ) ) {
499+ throw new Error ( `Unexpected input: name should not contain the delimiter "${ delimiter } "` ) ;
500+ }
501+ if ( convertedValue . includes ( delimiter ) ) {
502+ throw new Error ( `Unexpected input: value should not contain the delimiter "${ delimiter } "` ) ;
503+ }
504+ return `${ key } <<${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
505+ }
506+ exports . prepareKeyValueMessage = prepareKeyValueMessage ;
492507//# sourceMappingURL=file-command.js.map
493508
494509/***/ } ) ,
0 commit comments