Skip to content

Commit

Permalink
Promote action handler to async to make implementation simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jan 23, 2020
1 parent 165a3be commit 260345b
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions packages/create-block/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ program
.version( version )
.arguments( '[slug]' )
.option( '-t, --template <name>', 'template type name, allowed values: "es5", "esnext"', 'esnext' )
.action( ( slug, { template } ) => {
.action( async ( slug, { template } ) => {
try {
const defaultAnswers = getDefaultAnswers( template );
if ( slug ) {
Expand All @@ -44,19 +44,13 @@ program
slug,
title,
};
Promise.resolve()
.then( async () => {
await scaffold( template, answers );
} );
await scaffold( template, answers );
} else {
inquirer
.prompt( getPrompts( template ) )
.then( async ( answers ) => {
await scaffold( template, {
...defaultAnswers,
...answers,
} );
} );
const answers = await inquirer.prompt( getPrompts( template ) );
await scaffold( template, {
...defaultAnswers,
...answers,
} );
}
} catch ( e ) {
if ( e instanceof CLIError ) {
Expand Down

0 comments on commit 260345b

Please sign in to comment.