33
44const chokidar = require ( 'chokidar' ) ;
55const fs = require ( 'fs-extra' ) ;
6+ const escapeRegex = require ( 'escape-string-regexp' ) ;
67const debug = require ( 'debug' ) ( 'ember-cli-typescript:tsc:trace' ) ;
78
89module . exports = function compile ( project , tsOptions , callbacks ) {
@@ -23,7 +24,7 @@ module.exports = function compile(project, tsOptions, callbacks) {
2324 let host = ts . createWatchCompilerHost (
2425 configPath ,
2526 fullOptions ,
26- buildWatchHooks ( ts . sys , callbacks ) ,
27+ buildWatchHooks ( project , ts . sys , callbacks ) ,
2728 createProgram ,
2829 diagnosticCallback ( callbacks . reportDiagnostic ) ,
2930 diagnosticCallback ( callbacks . reportWatchStatus )
@@ -47,13 +48,17 @@ function diagnosticCallback(callback) {
4748 }
4849}
4950
50- function buildWatchHooks ( sys , callbacks ) {
51+ function buildWatchHooks ( project , sys , callbacks ) {
52+ let root = escapeRegex ( project . root ) ;
53+ let sep = `[/\\\\]` ;
54+ let patterns = [ '\\..*?' , 'dist' , 'node_modules' , 'tmp' ] ;
55+ let ignored = new RegExp ( `^${ root } ${ sep } (${ patterns . join ( '|' ) } )${ sep } ` ) ;
56+
5157 return Object . assign ( { } , sys , {
5258 watchFile : null ,
5359 watchDirectory ( dir , callback ) {
5460 if ( ! fs . existsSync ( dir ) ) return ;
5561
56- let ignored = / \/ ( \. .* ?| d i s t | n o d e _ m o d u l e s | t m p ) \/ / ;
5762 let watcher = chokidar . watch ( dir , { ignored, ignoreInitial : true } ) ;
5863
5964 watcher . on ( 'all' , ( type , path ) => {
0 commit comments