fix import local js file bug on "ag tidy"
This commit is contained in:
parent
d561868a76
commit
dea12f178a
10
main.go
10
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])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user