@@ -91,41 +91,36 @@ export function readJSON(path) {
9191export function runGen ( prompts , opts = { } ) {
9292 let options = opts . options || { skipInstall : true } ;
9393
94- return new Promise ( ( resolve , reject ) => {
95- let dir ;
96- let gen = helpers
97- . run ( require . resolve ( '../generators/app' ) )
98- . inTmpDir ( function ( _dir ) {
99- // this will create a new temporary directory for each new generator run
100- var done = this . async ( ) ;
101- if ( DEBUG ) console . log ( `TEMP DIR: ${ _dir } ` ) ;
102- dir = _dir ;
103-
104- let promises = [
105- fs . mkdirAsync ( dir + '/client' ) . then ( ( ) => {
106- return fs . symlinkAsync ( __dirname + '/fixtures/bower_components' , dir + '/client/bower_components' ) ;
107- } ) ,
108- fs . symlinkAsync ( __dirname + '/fixtures/node_modules' , dir + '/node_modules' )
109- ] ;
110-
111- if ( opts . copyConfigFile ) {
112- promises . push ( copyAsync ( path . join ( TEST_DIR , 'fixtures/.yo-rc.json' ) , path . join ( dir , '.yo-rc.json' ) ) ) ;
113- }
114-
115- // symlink our dependency directories
116- return Promise . all ( promises ) . then ( done ) ;
117- } )
118- . withGenerators ( [
119- require . resolve ( '../generators/endpoint' ) ,
120- // [helpers.createDummyGenerator(), 'ng-component:app']
121- ] )
122- // .withArguments(['upperCaseBug'])
123- . withOptions ( options ) ;
124-
125- if ( prompts ) gen . withPrompts ( prompts ) ;
126-
127- gen
128- . on ( 'error' , reject )
129- . on ( 'end' , ( ) => resolve ( dir ) ) ;
130- } ) ;
94+ // let dir;
95+ let gen = helpers
96+ . run ( require . resolve ( '../generators/app' ) )
97+ . inTmpDir ( function ( dir ) {
98+ // this will create a new temporary directory for each new generator run
99+ var done = this . async ( ) ;
100+ if ( DEBUG ) console . log ( `TEMP DIR: ${ dir } ` ) ;
101+
102+ let promises = [
103+ fs . mkdirAsync ( dir + '/client' ) . then ( ( ) => {
104+ return fs . symlinkAsync ( __dirname + '/fixtures/bower_components' , dir + '/client/bower_components' ) ;
105+ } ) ,
106+ fs . symlinkAsync ( __dirname + '/fixtures/node_modules' , dir + '/node_modules' )
107+ ] ;
108+
109+ if ( opts . copyConfigFile ) {
110+ promises . push ( copyAsync ( path . join ( TEST_DIR , 'fixtures/.yo-rc.json' ) , path . join ( dir , '.yo-rc.json' ) ) ) ;
111+ }
112+
113+ // symlink our dependency directories
114+ return Promise . all ( promises ) . then ( done ) ;
115+ } )
116+ . withGenerators ( [
117+ require . resolve ( '../generators/endpoint' ) ,
118+ // [helpers.createDummyGenerator(), 'ng-component:app']
119+ ] )
120+ // .withArguments(['upperCaseBug'])
121+ . withOptions ( options ) ;
122+
123+ if ( prompts ) gen . withPrompts ( prompts ) ;
124+
125+ return gen . toPromise ( ) ;
131126}
0 commit comments