move .build/types to .build/type + update checker accordingly
This commit is contained in:
parent
c7a6772b2b
commit
ee72e2d285
|
@ -9,9 +9,9 @@ import (
|
|||
)
|
||||
|
||||
// CreateRegistry creates an empty type registry
|
||||
// - if loadDir is TruE if will load all available types
|
||||
// - if loadDir is True if will load all available types
|
||||
// inside the local ./types folder
|
||||
func CreateRegistry(loadDir bool) *TypeRegistry {
|
||||
func CreateRegistry(loadDir ...string) *TypeRegistry {
|
||||
|
||||
/* (1) Create registry */
|
||||
reg := &TypeRegistry{
|
||||
|
@ -19,12 +19,12 @@ func CreateRegistry(loadDir bool) *TypeRegistry {
|
|||
}
|
||||
|
||||
/* (2) If no default to use -> empty registry */
|
||||
if !loadDir {
|
||||
if len(loadDir) < 1 {
|
||||
return reg
|
||||
}
|
||||
|
||||
/* (3) List types */
|
||||
plugins, err := ioutil.ReadDir("./types")
|
||||
plugins, err := ioutil.ReadDir(loadDir[0])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (tr *TypeRegistry) Add(pluginName string) error {
|
|||
}
|
||||
|
||||
/* (4) Try to load the plugin */
|
||||
p, err := plugin.Open(fmt.Sprintf("./types/%s", pluginName))
|
||||
p, err := plugin.Open(fmt.Sprintf(".build/type/%s", pluginName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -136,14 +136,14 @@ func main() {
|
|||
clifmt.Title("compile default types")
|
||||
err = buildTypes(
|
||||
dtPath,
|
||||
filepath.Join(projectPath, ".build/types"))
|
||||
filepath.Join(projectPath, ".build/type"))
|
||||
if err != nil {
|
||||
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
||||
}
|
||||
/* (4) Compile types */
|
||||
if compileTypes {
|
||||
clifmt.Title("compile types")
|
||||
err = buildTypes(tPath, filepath.Join(projectPath, ".build/types"))
|
||||
err = buildTypes(tPath, filepath.Join(projectPath, ".build/type"))
|
||||
if err != nil {
|
||||
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
||||
}
|
||||
|
|
|
@ -12,11 +12,9 @@ import (
|
|||
)
|
||||
|
||||
// Init initilises a new framework instance
|
||||
//
|
||||
// - path is the configuration path
|
||||
//
|
||||
// - if typeChecker is nil, defaults will be used (all *.so files
|
||||
// inside ./types local directory)
|
||||
// inside ./.build/types local directory)
|
||||
func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
||||
|
||||
/* (1) Init instance */
|
||||
|
@ -39,7 +37,7 @@ func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
|||
}
|
||||
|
||||
/* (4) Default registry creation */
|
||||
inst.Checker = checker.CreateRegistry(true)
|
||||
inst.Checker = checker.CreateRegistry(".build/type")
|
||||
|
||||
return inst, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue