feat(prebuild): add err reporting to builder & directive tasks.
This commit is contained in:
parent
865ce4c66b
commit
02e3334949
19 changed files with 108 additions and 53 deletions
|
|
@ -26,7 +26,7 @@ var (
|
|||
// Main directive interface
|
||||
type Directive interface {
|
||||
cfg.BaseInterface
|
||||
Apply(opt *Option, profile string) string
|
||||
Apply(opt *Option, profile string) (string, error)
|
||||
}
|
||||
|
||||
// Directive options
|
||||
|
|
@ -65,14 +65,18 @@ func RegisterDirective(d Directive) {
|
|||
Directives[d.Name()] = d
|
||||
}
|
||||
|
||||
func Run(file *paths.Path, profile string) string {
|
||||
func Run(file *paths.Path, profile string) (string, error) {
|
||||
var err error
|
||||
for _, match := range regDirective.FindAllStringSubmatch(profile, -1) {
|
||||
opt := NewOption(file, match)
|
||||
drtv, ok := Directives[opt.Name]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Unknown directive: %s", opt.Name))
|
||||
return "", fmt.Errorf("Unknown directive: %s", opt.Name)
|
||||
}
|
||||
profile, err = drtv.Apply(opt, profile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
profile = drtv.Apply(opt, profile)
|
||||
}
|
||||
return profile
|
||||
return profile, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue