1717 *
1818 * {code}
1919 * package set reinitWatchDelay=1000
20- * package set reinitWatchPaths= "config/**.cfc,handlers/**.cfc,models/**.cfc,ModuleConfig.cfc"
20+ * package set reinitWatchPaths="config/**.cfc,handlers/**.cfc,models/**.cfc,ModuleConfig.cfc"
21+ * package set reinitWatchDirectory="../"
2122 * {code}
2223 *
2324 * This command will run in the foreground until you stop it. When you are ready to shut down the watcher, press Ctrl+C.
@@ -33,14 +34,16 @@ component {
3334 variables .PATHS = " /config/**.cfc,/handlers/**.cfc,/models/**.cfc,/modules_app/**/*.cfc" ;
3435
3536 /**
36- * @paths Command delimited list of file globbing paths to watch relative to the working directory, defaults to **.cfc
37- * @delay How may milliseconds to wait before polling for changes, defaults to 500 ms
37+ * @paths Command delimited list of file globbing paths to watch relative to the working directory, defaults to **.cfc
38+ * @delay How may milliseconds to wait before polling for changes, defaults to 500 ms
3839 * @password Reinit password
40+ * @directory Working directory to start watcher in
3941 **/
4042 function run (
4143 string paths ,
4244 number delay ,
43- string password = " 1"
45+ string password = " 1" ,
46+ string directory
4447 ){
4548 // Get watch options from package descriptor
4649 var boxOptions = packageService .readPackageDescriptor ( getCWD () );
@@ -59,10 +62,14 @@ component {
5962
6063 // Determine watching patterns, either from arguments or boxoptions or defaults
6164 var globbingPaths = arguments .paths ?: getOptionsWatchers () ?: variables .PATHS ;
62- // handle non numeric config and put a floor of 150ms
63- var delayMs = max (
65+ var globArray = globbingPaths .listToArray ();
66+ var theDirectory = arguments .directory ?: boxOptions .reinitWatchDirectory ?: getCWD ();
67+ theDirectory = resolvePath ( theDirectory );
68+
69+ // handle non numeric config
70+ var delayMs = max (
6471 val ( arguments .delay ?: boxOptions .reinitWatchDelay ?: variables .WATCH_DELAY ),
65- 150
72+ variables . WATCH_DELAY
6673 );
6774 var statusColors = {
6875 " added" : " green" ,
@@ -95,15 +102,19 @@ component {
95102 .greenLine ( " ---------------------------------------------------" )
96103 .greenLine ( " Watching the following files for a framework reinit" )
97104 .greenLine ( " ---------------------------------------------------" )
98- .greenLine ( " " & globbingPaths )
105+ .line ();
106+ globArray .each ( ( p ) = > print .greenLine ( " " & p ) );
107+ print
108+ .line ()
109+ .greenLine ( " in directory: #theDirectory #" )
99110 .greenLine ( " Press Ctrl-C to exit " )
100111 .greenLine ( " ---------------------------------------------------" )
101112 .toConsole ();
102113
103114 // Start watcher
104115 watch ()
105- .paths ( globbingPaths . listToArray () )
106- .inDirectory ( getCWD () )
116+ .paths ( globArray )
117+ .inDirectory ( theDirectory )
107118 .withDelay ( delayMs )
108119 .onChange ( function ( changeData ){
109120 // output file changes
0 commit comments