@@ -3,6 +3,7 @@ import * as helpers from "../../common/helpers";
3
3
import * as path from "path" ;
4
4
import * as semver from "semver" ;
5
5
import * as fiberBootstrap from "../../common/fiber-bootstrap" ;
6
+ import Future = require( "fibers/future" ) ;
6
7
7
8
let gaze = require ( "gaze" ) ;
8
9
@@ -24,7 +25,8 @@ class LiveSyncService implements ILiveSyncService {
24
25
private $options : IOptions ,
25
26
private $logger : ILogger ,
26
27
private $dispatcher : IFutureDispatcher ,
27
- private $hooksService : IHooksService ) { }
28
+ private $hooksService : IHooksService ,
29
+ private $processService : IProcessService ) { }
28
30
29
31
private ensureAndroidFrameworkVersion ( platformData : IPlatformData ) : IFuture < void > { // TODO: this can be moved inside command or canExecute function
30
32
return ( ( ) => {
@@ -130,7 +132,7 @@ class LiveSyncService implements ILiveSyncService {
130
132
private partialSync ( syncWorkingDirectory : string , onChangedActions : ( ( event : string , filePath : string , dispatcher : IFutureDispatcher ) => void ) [ ] ) : void {
131
133
let that = this ;
132
134
133
- gaze ( "**/*" , { cwd : syncWorkingDirectory } , function ( err : any , watcher : any ) {
135
+ let gazeWatcher = gaze ( "**/*" , { cwd : syncWorkingDirectory } , function ( err : any , watcher : any ) {
134
136
this . on ( 'all' , ( event : string , filePath : string ) => {
135
137
fiberBootstrap . run ( ( ) => {
136
138
that . $dispatcher . dispatch ( ( ) => ( ( ) => {
@@ -147,6 +149,7 @@ class LiveSyncService implements ILiveSyncService {
147
149
} ) ;
148
150
} ) ;
149
151
152
+ this . $processService . attachToProcessExitSignals ( this , ( ) => Future . fromResult ( gazeWatcher . close ( ) ) ) ;
150
153
this . $dispatcher . run ( ) ;
151
154
}
152
155
}
0 commit comments