@@ -118,17 +118,29 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
118118 if len (function .Entrypoint ) == 0 {
119119 function .Entrypoint = filepath .Join (functionDir , "index.ts" )
120120 }
121+ denoJsonPath := filepath .Join (functionDir , "deno.json" )
122+ denoJsoncPath := filepath .Join (functionDir , "deno.jsonc" )
123+ importMapPath := filepath .Join (functionDir , "import_map.json" )
124+ packageJsonPath := filepath .Join (functionDir , "package.json" )
125+ checkPathExists := func (p string ) bool {
126+ if _ , err := fsys .Stat (p ); err == nil {
127+ return true
128+ }
129+ return false
130+ }
131+ denoJsonExists := checkPathExists (denoJsonPath )
132+ denoJsoncExists := checkPathExists (denoJsoncPath )
133+ importMapExists := checkPathExists (importMapPath )
134+ packageJsonExists := checkPathExists (packageJsonPath )
135+ function .UsePackageJson = ! denoJsonExists && ! denoJsoncExists && ! importMapExists && packageJsonExists
121136 if len (importMapPath ) > 0 {
122137 function .ImportMap = importMapPath
123138 } else if len (function .ImportMap ) == 0 {
124- denoJsonPath := filepath .Join (functionDir , "deno.json" )
125- denoJsoncPath := filepath .Join (functionDir , "deno.jsonc" )
126- importMapPath := filepath .Join (functionDir , "import_map.json" )
127- if _ , err := fsys .Stat (denoJsonPath ); err == nil {
139+ if denoJsonExists {
128140 function .ImportMap = denoJsonPath
129- } else if _ , err := fsys . Stat ( denoJsoncPath ); err == nil {
141+ } else if denoJsoncExists {
130142 function .ImportMap = denoJsoncPath
131- } else if _ , err := fsys . Stat ( importMapPath ); err == nil {
143+ } else if importMapExists {
132144 function .ImportMap = importMapPath
133145 functionsUsingDeprecatedImportMap = append (functionsUsingDeprecatedImportMap , name )
134146 } else if fallbackExists {
0 commit comments