@@ -62,18 +62,22 @@ function retrieveData({ debug: requestDebug, endpoint, configuration, auth, isTo
6262}
6363exports . retrieveData = retrieveData ;
6464/* Saves the data to the local file system and exports an environment variable containing the retrieved data. */
65- function generateExport ( { data, encoding, format, saveLocation, saveName, setOutput } ) {
65+ function generateExport ( { data, encoding, format, saveLocation, saveName, setOutput, variableName } ) {
6666 return __awaiter ( this , void 0 , void 0 , function * ( ) {
6767 ( 0 , core_1 . info ) ( 'Saving the data... 📁' ) ;
6868 const file = `${ saveLocation ? saveLocation : 'fetch-api-data-action' } /${ saveName ? saveName : 'data' } .${ format ? format : 'json' } ` ;
6969 const dataEncoding = encoding ? encoding : 'utf8' ;
70+ const defaultVariableName = 'fetchApiData' ;
71+ const environmentVariableName = variableName
72+ ? variableName
73+ : defaultVariableName ;
7074 try {
7175 yield ( 0 , io_1 . mkdirP ) ( `${ saveLocation ? saveLocation : 'fetch-api-data-action' } ` ) ;
7276 yield fs_1 . promises . writeFile ( file , data , dataEncoding ) ;
7377 ( 0 , core_1 . info ) ( `Saved ${ file } 💾` ) ;
7478 if ( setOutput ) {
75- ( 0 , core_1 . exportVariable ) ( 'fetchApiData' , data ) ;
76- ( 0 , core_1 . setOutput ) ( 'fetchApiData' , data ) ;
79+ ( 0 , core_1 . exportVariable ) ( environmentVariableName , data ) ;
80+ ( 0 , core_1 . setOutput ) ( defaultVariableName , data ) ;
7781 }
7882 return constants_1 . Status . SUCCESS ;
7983 }
0 commit comments