import * as gulpLoadPlugins from 'gulp-load-plugins' ; import { join } from 'path' ; import * as runSequence from 'run-sequence' ; import Config from '../../config' ; import { changeFileManager } from './code_change_tools' ; import { notifyLiveReload } from '../../utils' ; const plugins = < any > gulpLoadPlugins ( ) ; param { string } taskname export function watch ( taskname , root = Config . APP_SRC ) { return function ( ) { let paths = [ join ( root , '**' ) ] . concat ( Config . TEMP_FILES . map ( ( p ) => { return '!' + p ; } ) ) ; if ( Config . EXTRA_WATCH_PATHS ) { paths = paths . concat ( Config . EXTRA_WATCH_PATHS . map ( ( p ) => { return join ( p , '**' ) ; } ) ) ; } plugins . watch ( paths , ( e ) => { changeFileManager . addFile ( e . path ) ; setTimeout ( ( ) => { runSequence ( taskname , ( ) => { changeFileManager . clear ( ) ; notifyLiveReload ( e ) ; } ) ; } , 100 ) ; } ) ; } ; }