11import fs from 'fs-extra' ;
22import path from 'path' ;
3- import tmp from 'tmp' ;
43import execa from 'execa' ;
54import { EventEmitter } from 'events' ;
65import got from 'got' ;
76import debugLib from 'debug' ;
87
9- tmp . setGracefulCleanup ( ) ;
10-
118const debug = debugLib ( 'skeleton-app' ) ;
129
1310const getEmberPort = ( ( ) => {
@@ -18,16 +15,18 @@ const getEmberPort = (() => {
1815export default class SkeletonApp {
1916 port = getEmberPort ( ) ;
2017 watched : WatchedBuild | null = null ;
21- tmpDir = tmp . dirSync ( {
22- tries : 10 ,
23- unsafeCleanup : true ,
24- dir : process . cwd ( ) ,
25- template : 'test-skeleton-app-XXXXXX' ,
26- } ) ;
27- root = this . tmpDir . name ;
18+ cleanupTempDir = ( ) => fs . removeSync ( this . root ) ;
19+ root = path . join (
20+ process . cwd ( ) ,
21+ `test-skeleton-app- ${ Math . random ( )
22+ . toString ( 36 )
23+ . slice ( 2 ) } `
24+ ) ;
2825
2926 constructor ( ) {
27+ fs . mkdirpSync ( this . root ) ;
3028 fs . copySync ( `${ __dirname } /../../../test-fixtures/skeleton-app` , this . root ) ;
29+ process . on ( 'beforeExit' , this . cleanupTempDir ) ;
3130 }
3231
3332 build ( ) {
@@ -68,7 +67,9 @@ export default class SkeletonApp {
6867 if ( this . watched ) {
6968 this . watched . kill ( ) ;
7069 }
71- this . tmpDir . removeCallback ( ) ;
70+
71+ this . cleanupTempDir ( ) ;
72+ process . off ( 'beforeExit' , this . cleanupTempDir ) ;
7273 }
7374
7475 _ember ( args : string [ ] ) {
@@ -95,6 +96,7 @@ class WatchedBuild extends EventEmitter {
9596
9697 this . ember . catch ( error => {
9798 this . emit ( 'did-error' , error ) ;
99+ console . error ( error ) ;
98100 } ) ;
99101 }
100102
0 commit comments