goldsmith/loader.go

31 lines
545 B
Go
Raw Normal View History

2016-01-10 11:17:35 +00:00
package goldsmith
import "path/filepath"
2021-05-01 22:12:50 +00:00
type loader struct{}
2016-01-10 11:17:35 +00:00
2016-08-21 19:54:44 +00:00
func (*loader) Name() string {
return "loader"
}
2021-05-01 22:12:50 +00:00
func (*loader) Initialize(context *Context) error {
scannedInfo := make(chan fileInfo)
go scanDir(context.goldsmith.sourceDir, scannedInfo)
2016-01-10 11:17:35 +00:00
for info := range scannedInfo {
2016-06-11 20:13:16 +00:00
if info.IsDir() {
continue
}
2021-05-01 22:12:50 +00:00
relPath, _ := filepath.Rel(context.goldsmith.sourceDir, info.path)
file, err := context.CreateFileFromAsset(relPath, info.path)
if err != nil {
return err
2016-06-11 23:24:06 +00:00
}
2021-05-01 22:12:50 +00:00
context.DispatchFile(file)
2016-01-10 11:17:35 +00:00
}
2021-04-12 02:13:59 +00:00
return nil
2016-01-10 11:17:35 +00:00
}