x
This commit is contained in:
+36
-22
@@ -7,7 +7,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -33,29 +32,44 @@ func initNodePlugins() {
|
|||||||
plugins := []string{root}
|
plugins := []string{root}
|
||||||
os.Mkdir(root, 0755)
|
os.Mkdir(root, 0755)
|
||||||
fmt.Println("root", root)
|
fmt.Println("root", root)
|
||||||
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
|
||||||
fmt.Println("path", path)
|
files, _ := ioutil.ReadDir(root)
|
||||||
path = strings.ReplaceAll(path, "\\", "/")
|
for _, file := range files {
|
||||||
if !strings.HasPrefix(path, root+"/") {
|
if !file.IsDir() {
|
||||||
return nil
|
continue
|
||||||
}
|
}
|
||||||
files := strings.Split(strings.Replace(path, root+"/", "", 1), "/")
|
name := file.Name()
|
||||||
fmt.Println("files", files)
|
path := root + "/" + name
|
||||||
// var plugin_dir = false
|
plugins = append(plugins, path)
|
||||||
// var plugin_index = false
|
index := path + "/main.js"
|
||||||
switch len(files) {
|
if info, err := os.Stat(index); err == nil && !info.IsDir() {
|
||||||
case 1:
|
AddNodePlugin(index, name)
|
||||||
// plugin_dir = true
|
|
||||||
if info.IsDir() {
|
|
||||||
plugins = append(plugins, path)
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
if (files[1] == "main.js") && !info.IsDir() { //files[1] == "main.ts" ||
|
|
||||||
AddNodePlugin(path, files[0])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
}
|
||||||
})
|
|
||||||
|
// filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||||
|
// fmt.Println("path", path)
|
||||||
|
// path = strings.ReplaceAll(path, "\\", "/")
|
||||||
|
// if !strings.HasPrefix(path, root+"/") {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// files := strings.Split(strings.Replace(path, root+"/", "", 1), "/")
|
||||||
|
// fmt.Println("files", files)
|
||||||
|
// // var plugin_dir = false
|
||||||
|
// // var plugin_index = false
|
||||||
|
// switch len(files) {
|
||||||
|
// case 1:
|
||||||
|
// // plugin_dir = true
|
||||||
|
// if info.IsDir() {
|
||||||
|
// plugins = append(plugins, path)
|
||||||
|
// }
|
||||||
|
// case 2:
|
||||||
|
// if (files[1] == "main.js") && !info.IsDir() { //files[1] == "main.ts" ||
|
||||||
|
// AddNodePlugin(path, files[0])
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// })
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("创建监视器失败:", err)
|
fmt.Println("创建监视器失败:", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user