Refactor assistant script loading and improve error diagnostics
- Comment out assistant script loading in script package - Enhance global variable error message with detailed type information - Prepare for moving assistant script loading to a dedicated package
This commit is contained in:
parent
9c9f137a8a
commit
3c51f16d95
2 changed files with 18 additions and 19 deletions
|
|
@ -283,7 +283,7 @@ func global(info *v8go.FunctionCallbackInfo) (global *GlobalVariables, err error
|
||||||
|
|
||||||
global, ok := goGlobal.(*GlobalVariables)
|
global, ok := goGlobal.(*GlobalVariables)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("global is not a valid GlobalVariables")
|
return nil, fmt.Errorf("global is not a valid GlobalVariables. %#v", goGlobal)
|
||||||
}
|
}
|
||||||
|
|
||||||
return global, nil
|
return global, nil
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package script
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/yaoapp/gou/application"
|
"github.com/yaoapp/gou/application"
|
||||||
v8 "github.com/yaoapp/gou/runtime/v8"
|
v8 "github.com/yaoapp/gou/runtime/v8"
|
||||||
|
|
@ -26,26 +25,26 @@ func Load(cfg config.Config) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load assistants
|
// Load assistants - Move to the neo assistant package
|
||||||
err = application.App.Walk("assistants", func(root, file string, isdir bool) error {
|
// err = application.App.Walk("assistants", func(root, file string, isdir bool) error {
|
||||||
if isdir {
|
// if isdir {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Keep the src.index only
|
// // Keep the src.index only
|
||||||
if !strings.HasSuffix(file, "src/index.ts") {
|
// if !strings.HasSuffix(file, "src/index.ts") {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
id := fmt.Sprintf("assistants.%s", share.ID(root, file))
|
// id := fmt.Sprintf("assistants.%s", share.ID(root, file))
|
||||||
id = strings.TrimSuffix(id, ".src.index")
|
// id = strings.TrimSuffix(id, ".src.index")
|
||||||
_, err := v8.Load(file, id)
|
// _, err := v8.Load(file, id)
|
||||||
return err
|
// return err
|
||||||
}, exts...)
|
// }, exts...)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
return application.App.Walk("services", func(root, file string, isdir bool) error {
|
return application.App.Walk("services", func(root, file string, isdir bool) error {
|
||||||
if isdir {
|
if isdir {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue