@@ -17,7 +17,9 @@ const { systemHasCommand, isPortTaken, getAllFiles } = require('../utils');
1717const { runtimeNames, systemTools, JwtManager, Queue } = require ( '../emulation/utils' ) ;
1818const { dockerStop, dockerCleanup, dockerStart, dockerBuild, dockerPull } = require ( '../emulation/docker' ) ;
1919
20- const runFunction = async ( { port, functionId, noVariables, noReload, userId } = { } ) => {
20+ const runFunction = async ( { port, functionId, variables, reload, userId } = { } ) => {
21+ console . log ( variables ) ;
22+ console . log ( reload ) ;
2123 // Selection
2224 if ( ! functionId ) {
2325 const answers = await inquirer . prompt ( questionsRunFunctions [ 0 ] ) ;
@@ -113,17 +115,17 @@ const runFunction = async ({ port, functionId, noVariables, noReload, userId } =
113115 }
114116
115117 const userVariables = { } ;
116- const variables = { } ;
118+ const allVariables = { } ;
117119
118- if ( ! noVariables ) {
120+ if ( variables ) {
119121 try {
120122 const { variables : remoteVariables } = await paginate ( functionsListVariables , {
121123 functionId : func [ '$id' ] ,
122124 parseOutput : false
123125 } , 100 , 'variables' ) ;
124126
125127 remoteVariables . forEach ( ( v ) => {
126- variables [ v . key ] = v . value ;
128+ allVariables [ v . key ] = v . value ;
127129 userVariables [ v . key ] = v . value ;
128130 } ) ;
129131 } catch ( err ) {
@@ -137,18 +139,18 @@ const runFunction = async ({ port, functionId, noVariables, noReload, userId } =
137139 const env = parseDotenv ( fs . readFileSync ( envPath ) . toString ( ) ?? '' ) ;
138140
139141 Object . keys ( env ) . forEach ( ( key ) => {
140- variables [ key ] = env [ key ] ;
142+ allVariables [ key ] = env [ key ] ;
141143 userVariables [ key ] = env [ key ] ;
142144 } ) ;
143145 }
144146
145- variables [ 'APPWRITE_FUNCTION_API_ENDPOINT' ] = globalConfig . getFrom ( 'endpoint' ) ;
146- variables [ 'APPWRITE_FUNCTION_ID' ] = func . $id ;
147- variables [ 'APPWRITE_FUNCTION_NAME' ] = func . name ;
148- variables [ 'APPWRITE_FUNCTION_DEPLOYMENT' ] = '' ; // TODO: Implement when relevant
149- variables [ 'APPWRITE_FUNCTION_PROJECT_ID' ] = localConfig . getProject ( ) . projectId ;
150- variables [ 'APPWRITE_FUNCTION_RUNTIME_NAME' ] = runtimeNames [ runtimeName ] ?? '' ;
151- variables [ 'APPWRITE_FUNCTION_RUNTIME_VERSION' ] = func . runtime ;
147+ allVariables [ 'APPWRITE_FUNCTION_API_ENDPOINT' ] = globalConfig . getFrom ( 'endpoint' ) ;
148+ allVariables [ 'APPWRITE_FUNCTION_ID' ] = func . $id ;
149+ allVariables [ 'APPWRITE_FUNCTION_NAME' ] = func . name ;
150+ allVariables [ 'APPWRITE_FUNCTION_DEPLOYMENT' ] = '' ; // TODO: Implement when relevant
151+ allVariables [ 'APPWRITE_FUNCTION_PROJECT_ID' ] = localConfig . getProject ( ) . projectId ;
152+ allVariables [ 'APPWRITE_FUNCTION_RUNTIME_NAME' ] = runtimeNames [ runtimeName ] ?? '' ;
153+ allVariables [ 'APPWRITE_FUNCTION_RUNTIME_VERSION' ] = func . runtime ;
152154
153155 try {
154156 await JwtManager . setup ( userId , func . scopes ?? [ ] ) ;
@@ -162,7 +164,7 @@ const runFunction = async ({ port, functionId, noVariables, noReload, userId } =
162164 headers [ 'x-appwrite-event' ] = '' ;
163165 headers [ 'x-appwrite-user-id' ] = userId ?? '' ;
164166 headers [ 'x-appwrite-user-jwt' ] = JwtManager . userJwt ?? '' ;
165- variables [ 'OPEN_RUNTIMES_HEADERS' ] = JSON . stringify ( headers ) ;
167+ allVariables [ 'OPEN_RUNTIMES_HEADERS' ] = JSON . stringify ( headers ) ;
166168
167169 if ( Object . keys ( userVariables ) . length > 0 ) {
168170 drawTable ( Object . keys ( userVariables ) . map ( ( key ) => ( {
@@ -180,7 +182,7 @@ const runFunction = async ({ port, functionId, noVariables, noReload, userId } =
180182 process . stdout . write ( chalk . white ( `${ data } \n` ) ) ;
181183 } ) ;
182184
183- if ( ! noReload ) {
185+ if ( reload ) {
184186 const ignorer = ignore ( ) ;
185187 ignorer . add ( '.appwrite' ) ;
186188 ignorer . add ( 'code.tar.gz' ) ;
0 commit comments