@@ -171,38 +171,37 @@ function runMigration(currentConfigPath: string, outputConfigPath: string): Prom
171171 * function.
172172 */
173173
174- export default function migrate ( ...args : string [ ] ) : void | Promise < void > {
174+ export default async function migrate ( ...args : string [ ] ) : Promise < void > {
175175 const filePaths = args ;
176176 if ( ! filePaths . length ) {
177177 logger . error ( '\n ✖ Please specify a path to your webpack config\n' ) ;
178178 return ;
179179 }
180180
181- const currentConfigPath = path . resolve ( process . cwd ( ) , filePaths [ 0 ] ) ;
181+ const currentConfigPath = path . resolve ( filePaths [ 0 ] ) ;
182182 let outputConfigPath : string ;
183183
184184 if ( ! filePaths [ 1 ] ) {
185- return inquirer
186- . prompt ( [
185+ try {
186+ const { confirmPath } = await inquirer . prompt ( [
187187 {
188188 default : 'Y' ,
189- message : 'Migration output path not specified. ' + ' Do you want to use your existing webpack ' + ' configuration?',
189+ message : 'Migration output path not specified. Do you want to use your existing webpack configuration?' ,
190190 name : 'confirmPath' ,
191191 type : 'confirm' ,
192192 } ,
193- ] )
194- . then ( ( ans : { confirmPath : boolean } ) : void | Promise < void > => {
195- if ( ! ans . confirmPath ) {
196- logger . error ( '✖ ︎Migration aborted due to no output path' ) ;
197- return ;
198- }
199- outputConfigPath = path . resolve ( process . cwd ( ) , filePaths [ 0 ] ) ;
200- return runMigration ( currentConfigPath , outputConfigPath ) ;
201- } )
202- . catch ( ( err : object ) : void => {
203- logger . error ( err ) ;
204- } ) ;
193+ ] ) ;
194+ if ( ! confirmPath ) {
195+ logger . error ( '✖ ︎Migration aborted due to no output path' ) ;
196+ return ;
197+ }
198+ outputConfigPath = path . resolve ( filePaths [ 0 ] ) ;
199+ return runMigration ( currentConfigPath , outputConfigPath ) ;
200+ } catch ( err ) {
201+ logger . error ( err ) ;
202+ return ;
203+ }
205204 }
206- outputConfigPath = path . resolve ( process . cwd ( ) , filePaths [ 1 ] ) ;
205+ outputConfigPath = path . resolve ( filePaths [ 1 ] ) ;
207206 return runMigration ( currentConfigPath , outputConfigPath ) ;
208207}
0 commit comments