3
3
4
4
const chokidar = require ( 'chokidar' ) ;
5
5
const fs = require ( 'fs-extra' ) ;
6
+ const escapeRegex = require ( 'escape-string-regexp' ) ;
6
7
const debug = require ( 'debug' ) ( 'ember-cli-typescript:tsc:trace' ) ;
7
8
8
9
module . exports = function compile ( project , tsOptions , callbacks ) {
@@ -23,7 +24,7 @@ module.exports = function compile(project, tsOptions, callbacks) {
23
24
let host = ts . createWatchCompilerHost (
24
25
configPath ,
25
26
fullOptions ,
26
- buildWatchHooks ( ts . sys , callbacks ) ,
27
+ buildWatchHooks ( project , ts . sys , callbacks ) ,
27
28
createProgram ,
28
29
diagnosticCallback ( callbacks . reportDiagnostic ) ,
29
30
diagnosticCallback ( callbacks . reportWatchStatus )
@@ -47,13 +48,17 @@ function diagnosticCallback(callback) {
47
48
}
48
49
}
49
50
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
+
51
57
return Object . assign ( { } , sys , {
52
58
watchFile : null ,
53
59
watchDirectory ( dir , callback ) {
54
60
if ( ! fs . existsSync ( dir ) ) return ;
55
61
56
- let ignored = / \/ ( \. .* ?| d i s t | n o d e _ m o d u l e s | t m p ) \/ / ;
57
62
let watcher = chokidar . watch ( dir , { ignored, ignoreInitial : true } ) ;
58
63
59
64
watcher . on ( 'all' , ( type , path ) => {
0 commit comments