@@ -63,7 +63,7 @@ function updateCheck() {
6363 }
6464}
6565
66- function pre ( ) {
66+ async function pre ( ) {
6767 // Debugging helper
6868 if ( cmd === 'doctor' ) {
6969 require ( 'yeoman-doctor' ) ( ) ;
@@ -80,7 +80,7 @@ function pre() {
8080 return ;
8181 }
8282
83- init ( ) ;
83+ await init ( ) ;
8484}
8585
8686function createGeneratorList ( env ) {
@@ -117,11 +117,13 @@ const onError = error => {
117117 process . exit ( error . code || 1 ) ;
118118} ;
119119
120- function init ( ) {
121- const env = require ( 'yeoman-environment' ) . createEnv ( ) ;
120+ async function init ( ) {
121+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
122+ const { createEnv} = await import ( 'yeoman-environment' ) ;
123+ const env = createEnv ( ) ;
122124
123125 // Lookup for every namespaces, within the environments.paths and lookups
124- env . lookup ( firstCmd . opts . localOnly || false ) ;
126+ await env . lookup ( firstCmd . opts . localOnly || false ) ;
125127 const generatorList = createGeneratorList ( env ) ;
126128
127129 // List generators
@@ -153,7 +155,7 @@ function init() {
153155 console . log ( chalk . red ( 'Installed generators don\'t need the "generator-" prefix.' ) ) ;
154156 console . log ( `In the future, run ${ generatorCommand } instead!\n` ) ;
155157
156- env . run ( generatorName , firstCmd . opts ) . catch ( error => onError ( error ) ) ;
158+ await env . run ( generatorName , firstCmd . opts ) . catch ( error => onError ( error ) ) ;
157159
158160 return ;
159161 }
@@ -162,7 +164,8 @@ function init() {
162164 // one that will be triggered by the below args. Maybe the nopt parsing
163165 // should be done internally, from the args.
164166 for ( const gen of cli ) {
165- env . run ( gen . args , gen . opts ) . catch ( error => onError ( error ) ) ;
167+ // eslint-disable-next-line no-await-in-loop
168+ await env . run ( gen . args , gen . opts ) . catch ( error => onError ( error ) ) ;
166169 }
167170}
168171
@@ -186,4 +189,6 @@ rootCheck('\n' + chalk.red('Easy with the `sudo`. Yeoman is the master around he
186189
187190updateCheck ( ) ;
188191
189- pre ( ) ;
192+ ( async function ( ) {
193+ await pre ( ) ;
194+ } ) ( ) ;
0 commit comments