@@ -62,7 +62,7 @@ func (project *Project) namespaceTaskName(name string) (namespace string, taskNa
6262}
6363
6464func (project * Project ) debounce (task * Task ) bool {
65- debounceMs := task .Debounce
65+ debounceMs := task .debounce
6666 if debounceMs == 0 {
6767 debounceMs = DebounceMs
6868 }
@@ -135,7 +135,7 @@ func (project *Project) usage() string {
135135
136136 for _ , name := range names {
137137 task := m [name ]
138- description := task .Description
138+ description := task .description
139139 if description == "" {
140140 if len (task .Dependencies ) > 0 {
141141 description = "Runs {" + strings .Join (task .Dependencies , ", " ) + ", " + name + "} tasks"
@@ -156,6 +156,36 @@ func (project *Project) Use(namespace string, tasksFunc func(*Project)) {
156156 project .Namespace [namespace ] = proj
157157}
158158
159+ func printDeprecatedWatchWarning (name string , globs []string ) {
160+ if ! deprecatedWarnings {
161+ return
162+ }
163+ util .Deprecate (fmt .Sprintf (`W{} and Watch{} are deprecated. Use Task#Watch()
164+ p.Task("%s", func(){
165+ }).Watch(%q)
166+ ` , name , globs [0 ]))
167+ }
168+
169+ func printDeprecatedDebounceWarning (name string , ms int64 ) {
170+ if ! deprecatedWarnings {
171+ return
172+ }
173+ util .Deprecate (fmt .Sprintf (`Debounce() option is deprecated. Use Task#Debounce()
174+ p.Task("%s", func(){
175+ }).Debounce(%d)
176+ ` , name , ms ))
177+ }
178+
179+ func printDeprecatedDescriptionWarning (name string , desc string ) {
180+ if ! deprecatedWarnings {
181+ return
182+ }
183+ util .Deprecate (fmt .Sprintf (`Description option is deprecated. Use Task#Description()
184+ p.Task("%s", func(){
185+ }).Description(%q)
186+ ` , name , desc ))
187+ }
188+
159189// Task adds a task to the project.
160190func (project * Project ) Task (name string , args ... interface {}) * Task {
161191 runOnce := false
@@ -170,21 +200,25 @@ func (project *Project) Task(name string, args ...interface{}) *Task {
170200 default :
171201 util .Panic ("project" , "unexpected type %T\n " , t ) // %T prints whatever type t has
172202 case Watch :
173- task .WatchGlobs = t
203+ task .Watch (t ... )
204+ printDeprecatedWatchWarning (name , t )
174205 case W :
175- task .WatchGlobs = t
206+ task .Watch (t ... )
207+ printDeprecatedWatchWarning (name , t )
176208 case Dependencies :
177209 task .Dependencies = t
178210 case D :
179211 task .Dependencies = t
180212 case Debounce :
181- task .Debounce = int64 (t )
213+ task .Debounce (int64 (t ))
214+ printDeprecatedDebounceWarning (name , int64 (t ))
182215 case func ():
183216 task .Handler = t
184217 case func (* Context ):
185218 task .ContextHandler = t
186219 case string :
187- task .Description = t
220+ task .Description (t )
221+ printDeprecatedDescriptionWarning (name , t )
188222 }
189223 }
190224 project .Tasks [name ] = task
@@ -197,7 +231,6 @@ func watchTask(root string, logName string, handler func(e *watcher.FileEvent))
197231 if err != nil {
198232 util .Panic ("project" , "%v\n " , err )
199233 }
200- //waitTime := time.Duration(0.1 * float64(time.Second))
201234 watchr .WatchRecursive (root )
202235 watchr .ErrorHandler = func (err error ) {
203236 util .Error ("project" , "%v\n " , err )
@@ -220,8 +253,6 @@ func watchTask(root string, logName string, handler func(e *watcher.FileEvent))
220253 continue
221254 }
222255 handler (event )
223- // prevent multiple restart in short time
224- //time.Sleep(waitTime)
225256 }
226257}
227258
0 commit comments