index.js
function watch(tasks) {

   if (tasks["watch"]) {
      console.warn("`watch` task redefined.")
      return
   }

   const names = Object.keys(tasks).filter((name) => tasks[name].watch)
   if (!names.length)
      return


   gulp.task("watch", () => {
      for (const name of names) {
         const glob = tasks[name].watch
         const watcher = gulp.watch(glob, gulp.task(name))
         watcher.on("change", (path) => console.log(`${timestamp()} '${path}' was changed, running tasks...`))
      }
   })

}
function watch(tasks) {

   if (tasks["watch"]) {
      console.warn("`watch` task redefined.")
      return
   }

   const names = Object.keys(tasks).filter((name) => tasks[name].watch)
   if (!names.length)
      return


   gulp.task("watch", () => {
      for (const name of names) {
         const glob = tasks[name].watch
         const watcher = gulp.watch(glob, gulp.task(name))
         watcher.on("change", (path) => console.log(`${timestamp()} '${path}' was changed, running tasks...`))
      }
   })

}
function watch ( tasks ) { if ( tasks [ "watch" ] ) { console . warn ( "`watch` task redefined." ) return } const names = Object . keys ( tasks ) . filter ( ( name ) => tasks [ name ] . watch ) if ( ! names . length ) return gulp . task ( "watch" , ( ) => { for ( const name of names ) { const glob = tasks [ name ] . watch const watcher = gulp . watch ( glob , gulp . task ( name ) ) watcher . on ( "change" , ( path ) => console . log ( ` ${ timestamp ( ) } ${ path } ` ) ) } } ) }
Create the watch task if declared and triggered. Only top level tasks may be watched.
Create the watch task if declared and triggered . Only top level tasks may be watched .