@@ -121,17 +121,42 @@ async function generateFunctions() {
121121}
122122
123123async function runFunc ( ...args : string [ ] ) {
124- const cmd = [ "func" , ...args ] ;
125- console . info ( `Starting Azure Functions Core Tools: ${ cmd . join ( " " ) } ` ) ;
126- const proc = Deno . run ( { cmd } ) ;
127- await proc . status ( ) ;
124+ let cmd = [ "func" , ...args ] ;
125+ const env = {
126+ "logging__logLevel__Microsoft" : "warning" ,
127+ "logging__logLevel__Worker" : "warning"
128+ } ;
129+ try {
130+ console . info ( `Running Azure Functions Core Tools: ${ cmd . join ( " " ) } ` ) ;
131+ const proc = Deno . run ( { cmd, env } ) ;
132+ await proc . status ( ) ;
133+ } catch ( ex ) {
134+ if ( Deno . build . os === "windows" ) {
135+ console . info ( "Could not start func from path, searching for executable..." )
136+ cmd = [ "where.exe" , "func" ] ;
137+ const proc = Deno . run ( {
138+ cmd,
139+ stdout : "piped"
140+ } ) ;
141+ await proc . status ( ) ;
142+ const rawOutput = await proc . output ( ) ;
143+ const funcPath = new TextDecoder ( ) . decode ( rawOutput ) . split ( / \r ? \n / ) . find ( p => p . endsWith ( "func.cmd" ) ) ;
144+ if ( funcPath ) {
145+ cmd = [ funcPath , ...args ] ;
146+ console . info ( `Running Azure Functions Core Tools: ${ cmd . join ( " " ) } ` ) ;
147+ const proc = Deno . run ( { cmd, env } ) ;
148+ await proc . status ( ) ;
149+ } else {
150+ throw "Could not located func. Please ensure it is installed and in the path." ;
151+ }
152+ } else {
153+ throw ex ;
154+ }
155+ }
128156}
129157
130158async function publishApp ( appName : string ) {
131- const cmd = [ "func" , "azure" , "functionapp" , "publish" , appName , "--no-build" , "-b" , "local" , "--force" ] ;
132- console . info ( `Publishing app: ${ cmd . join ( " " ) } ` ) ;
133- const proc = Deno . run ( { cmd } ) ;
134- await proc . status ( ) ;
159+ await runFunc ( "azure" , "functionapp" , "publish" , appName , "--no-build" , "-b" , "local" , "--force" ) ;
135160}
136161
137162function printLogo ( ) {
0 commit comments