diff --git a/main.go b/main.go index c156bdd..af2df3c 100644 --- a/main.go +++ b/main.go @@ -516,7 +516,15 @@ func makeJsImports(path string, jsImports *[]string, pkgName string) { if code, err := u.ReadFile(fullName); err == nil { for _, m := range importMatcher.FindAllStringSubmatch(code, 1024) { if !strings.HasPrefix(m[2], ".") && !strings.HasPrefix(m[2], "_") && m[2] != "current-plugin" && m[2] != "console" && m[2] != "logger" { - if !u.FileExists(filepath.Join(path, m[2])) { + checkFile := filepath.Join(path, m[2]) + checkFileInfo := u.GetFileInfo(checkFile) + if checkFileInfo != nil && checkFileInfo.IsDir { + checkFile = filepath.Join(checkFile, "index.js") + } else if !strings.HasSuffix(checkFile, ".js") { + checkFile += ".js" + } + //fmt.Println(u.BMagenta(checkFile), u.FileExists(checkFile)) + if !u.FileExists(checkFile) { *jsImports = u.AppendUniqueString(*jsImports, m[2]) } }