@@ -37,22 +37,30 @@ module.exports = class SkeletonApp {
37
37
this . _watched . kill ( ) ;
38
38
}
39
39
40
- // Windows doesn't necessarily kill the process immediately, so
41
- // leave a little time before trying to remove the directory.
42
- setTimeout ( ( ) => {
43
- try {
44
- fs . removeSync ( this . appDir ) ;
45
- } catch ( error ) {
46
- // eslint-disable-next-line no-console
47
- console . warn ( `Warning: unable to remove skeleton-app tmpdir ${ this . appDir } (${ error . code } )` ) ;
48
- }
49
- } , 250 ) ;
40
+ this . _cleanupAppDir ( { retries : 1 } ) ;
50
41
}
51
42
52
43
_ember ( args ) {
53
44
let ember = require . resolve ( 'ember-cli/bin/ember' ) ;
54
45
return execa ( 'node' , [ ember ] . concat ( args ) , { cwd : this . appDir } ) ;
55
46
}
47
+
48
+ _cleanupAppDir ( options ) {
49
+ let retries = options && options . retries || 0 ;
50
+
51
+ try {
52
+ fs . removeSync ( this . appDir ) ;
53
+ } catch ( error ) {
54
+ if ( retries > 0 ) {
55
+ // Windows doesn't necessarily kill the process immediately, so
56
+ // leave a little time before trying to remove the directory.
57
+ setTimeout ( ( ) => this . _cleanupAppDir ( { retries : retries - 1 } ) , 250 ) ;
58
+ } else {
59
+ // eslint-disable-next-line no-console
60
+ console . warn ( `Warning: unable to remove skeleton-app tmpdir ${ this . appDir } (${ error . code } )` ) ;
61
+ }
62
+ }
63
+ }
56
64
}
57
65
58
66
class WatchedBuild extends EventEmitter {
@@ -62,14 +70,19 @@ class WatchedBuild extends EventEmitter {
62
70
this . _ember . stdout . on ( 'data' , ( data ) => {
63
71
let output = data . toString ( ) ;
64
72
if ( output . includes ( 'Build successful' ) ) {
65
- this . emit ( 'rebuild-complete ' ) ;
73
+ this . emit ( 'did-rebuild ' ) ;
66
74
}
67
75
} ) ;
76
+
77
+ this . _ember . catch ( ( error ) => {
78
+ this . emit ( 'did-error' , error ) ;
79
+ } ) ;
68
80
}
69
81
70
82
waitForBuild ( ) {
71
- return new Promise ( ( resolve ) => {
72
- this . once ( 'rebuild-complete' , resolve ) ;
83
+ return new Promise ( ( resolve , reject ) => {
84
+ this . once ( 'did-rebuild' , resolve ) ;
85
+ this . once ( 'did-error' , reject ) ;
73
86
} ) ;
74
87
}
75
88
0 commit comments