From 0858a23223ba5b936a92ff3a84ecb803bec226d1 Mon Sep 17 00:00:00 2001 From: 1-6 Date: Mon, 31 Jul 2023 14:47:39 +0800 Subject: [PATCH] x --- core/grpc_plugins.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/grpc_plugins.go b/core/grpc_plugins.go index 8027f1b..43a1eae 100644 --- a/core/grpc_plugins.go +++ b/core/grpc_plugins.go @@ -217,7 +217,8 @@ func AddNodePlugin(path, name string) error { f.Suffix = ".js" f.Type = "node" f.Path = path - f.Handle = func(s common.Sender, f func(vm *goja.Runtime)) interface{} { + f.Handle = func(s common.Sender, _ func(vm *goja.Runtime)) interface{} { + console := &Console{UUID: uuid} s.SetPluginID(uuid) plt := s.GetImType() cmd := exec.Command("./node", path) @@ -261,12 +262,23 @@ func AddNodePlugin(path, name string) error { go func() { defer wg.Done() scanner := bufio.NewScanner(stderr) - for scanner.Scan() { - data := scanner.Text() - fmt.Println(data) - // if _, err := file.WriteString(data + "\n"); err != nil { - // fmt.Printf("写入文件失败:%v\n", err) - // } + if f.OnStart { + for scanner.Scan() { + data := scanner.Text() + // lines = append(lines, data) + fmt.Println(data) + // if _, err := file.WriteString(data + "\n"); err != nil { + // fmt.Printf("写入文件失败:%v\n", err) + // } + } + } else { + // lines := []string{} + for scanner.Scan() { + data := scanner.Text() + fmt.Println(data) + // lines = append(lines, data) + } + // console.Error(strings.Join(lines, "\n")) } }() processes.Store(cmd, s)