reorganize into newFSNotifyTrigger function
@@ -48,6 +48,15 @@ func NewTrigger(runctx *runcontext.RunContext) (Trigger, error) {
Interval: time.Duration(runctx.Opts.WatchPollInterval) * time.Millisecond,
}, nil
case "notify":
+ return newFSNotifyTrigger(runctx)
+ case "manual":
+ return &manualTrigger{}, nil
+ default:
+ return nil, fmt.Errorf("unsupported trigger: %s", runctx.Opts.Trigger)
+ }
+}
+
+func newFSNotifyTrigger(runctx *runcontext.RunContext) (*fsNotifyTrigger, error) {
workspaces := map[string]struct{}{}
for _, a := range runctx.Cfg.Build.Artifacts {
workspaces[a.Workspace] = struct{}{}
@@ -56,11 +65,6 @@ func NewTrigger(runctx *runcontext.RunContext) (Trigger, error) {
Interval: time.Duration(runctx.Opts.WatchPollInterval) * time.Millisecond,
workspaces: workspaces,
}, nil
- case "manual":
- return &manualTrigger{}, nil
- default:
- return nil, fmt.Errorf("unsupported trigger: %s", runctx.Opts.Trigger)
- }
}
// pollTrigger watches for changes on a given interval of time.
