11"use strict" ;
22
3- let makeWatcher = require ( "nite-owl" ) ;
43let path = require ( "path" ) ;
54
65const PLUGINS = {
@@ -17,18 +16,7 @@ module.exports = (rootDir, config = "faucet.config.js", // eslint-disable-next-l
1716
1817 let watcher ;
1918 if ( watch ) {
20- let { watchDirs } = config ;
21- /* eslint-disable indent */
22- watchDirs = watchDirs ?
23- watchDirs . map ( dir => path . resolve ( configDir , dir ) ) :
24- [ configDir ] ;
25- /* eslint-enable indent */
26-
27- let separator = watchDirs . length === 1 ? " " : "\n" ;
28- console . error ( "monitoring file system at" + separator +
29- watchDirs . join ( separator ) ) ;
30-
31- watcher = makeWatcher ( watchDirs ) ;
19+ watcher = makeWatcher ( config . watchDirs , configDir ) ;
3220 }
3321
3422 Object . keys ( PLUGINS ) . forEach ( type => {
@@ -51,3 +39,30 @@ function load(pkg) {
5139 process . exit ( 1 ) ;
5240 }
5341}
42+
43+ function makeWatcher ( watchDirs , configDir ) {
44+ let niteOwl = require ( "nite-owl" ) ;
45+
46+ /* eslint-disable indent */
47+ watchDirs = watchDirs ?
48+ watchDirs . map ( dir => path . resolve ( configDir , dir ) ) :
49+ [ configDir ] ;
50+ /* eslint-enable indent */
51+
52+ let separator = watchDirs . length === 1 ? " " : "\n" ;
53+ console . error ( "monitoring file system at" + separator + watchDirs . join ( separator ) ) ;
54+
55+ let watcher = niteOwl ( watchDirs ) ;
56+ watcher . on ( "error" , err => {
57+ if ( err . code === "ERR_TOO_MANY_FILES" ) {
58+ console . error ( "There are too many files being monitored, " +
59+ "please use the `watchDirs` configuration setting:\n" +
60+ // eslint-disable-next-line max-len
61+ "https://github.com/faucet-pipeline/faucet-pipeline#configuration-for-file-watching" ) ;
62+ process . exit ( 1 ) ;
63+ }
64+
65+ throw err ;
66+ } ) ;
67+ return watcher ;
68+ }
0 commit comments