@@ -6,6 +6,7 @@ const meow = require('meow');
6
6
const puppeteer = require ( 'puppeteer' ) ;
7
7
const liveServer = require ( 'live-server' ) ;
8
8
const chalk = require ( 'chalk' ) ;
9
+ const ora = require ( 'ora' ) ;
9
10
10
11
const cli = meow ( {
11
12
description : false ,
@@ -93,16 +94,17 @@ function serve() {
93
94
}
94
95
95
96
function init ( flags ) {
97
+ const spinner = ora ( 'Initializing ...' ) . start ( ) ;
96
98
const { name} = flags ;
97
99
const presentationPath = path . resolve ( name ) ;
98
- const presentationName = path . basename ( presentationPath ) ;
99
100
100
101
if ( fs . existsSync ( presentationPath ) ) {
101
- abort ( `The directory ' ${ presentationName } ' is already existing.` ) ;
102
+ abort ( `The directory ${ chalk . underline ( name ) } is already existing.` , spinner ) ;
102
103
}
103
104
104
105
fs . mkdirSync ( presentationPath ) ;
105
106
fs . copySync ( path . resolve ( __dirname , 'template' ) , presentationPath ) ;
107
+ spinner . succeed ( `Directory ${ chalk . underline ( name ) } has been initialized.` ) ;
106
108
}
107
109
108
110
function update ( ) {
@@ -148,8 +150,13 @@ function print(flags) {
148
150
} ) ( ) ;
149
151
}
150
152
151
- function abort ( message ) {
152
- console . error ( message ) ;
153
+ function abort ( message , spinner = null ) {
154
+ if ( spinner ) {
155
+ spinner . fail ( message ) ;
156
+ } else {
157
+ console . error ( message ) ;
158
+ }
159
+
153
160
console . error ( 'Aborting.' ) ;
154
161
process . exit ( 1 ) ;
155
162
}
0 commit comments