1
- var program = require ( 'commander' ) ;
2
- var chalk = require ( 'chalk' ) ;
3
- var elegantSpinner = require ( 'elegant-spinner' ) ;
4
- var logUpdate = require ( 'log-update' ) ;
5
- var frame = elegantSpinner ( ) ;
1
+ import program from 'commander' ;
2
+ import chalk from 'chalk' ;
3
+ import elegantSpinner from 'elegant-spinner' ;
4
+ import logUpdate from 'log-update' ;
5
+ import pjson from '../../package.json' ;
6
6
require ( 'shelljs/global' ) ;
7
- var pjson = require ( '../../package.json' ) ;
8
7
8
+ const frame = elegantSpinner ( ) ;
9
9
10
10
program
11
- . version ( pjson . version )
12
- . description ( 'Create a MERN app in current directory!' )
13
- . option ( '-v, --version' , 'check version' )
14
- . parse ( process . argv ) ;
11
+ . version ( pjson . version )
12
+ . description ( 'Create a MERN app in current directory!' )
13
+ . option ( '-v, --version' , 'check version' )
14
+ . parse ( process . argv ) ;
15
15
16
16
17
17
if ( ! which ( 'git' ) ) {
18
- console . log ( chalk . red ( 'Sorry, this script requires git' ) ) ;
19
- exit ( 1 ) ;
18
+ console . log ( chalk . red ( 'Sorry, this script requires git' ) ) ;
19
+ exit ( 1 ) ;
20
20
}
21
21
22
- if ( program . args . length > 1 ) {
23
- console . log ( chalk . red ( 'Please give only one argument as a directory name!!!' ) ) ;
24
- exit ( 1 ) ;
22
+ if ( program . args . length > 1 ) {
23
+ console . log ( chalk . red ( 'Please give only one argument as a directory name!!!' ) ) ;
24
+ exit ( 1 ) ;
25
25
}
26
26
27
- if ( program . args . length === 1 ) {
28
- if ( test ( '-d' , program . args [ 0 ] ) ) {
29
- console . log ( chalk . red ( program . args [ 0 ] + ' directory already exits! Please choose some another name!!!' ) ) ;
30
- exit ( 1 ) ;
31
- }
32
-
33
- mkdir ( '-p' , program . args [ 0 ] ) ;
34
- cd ( program . args [ 0 ] ) ;
35
- }
36
- exec ( 'git init' ) ;
37
-
38
- var interval = setInterval ( function ( ) {
39
- logUpdate ( "Fetching the boilerplate..." + chalk . cyan . bold . dim ( frame ( ) ) ) ;
40
- } , 50 )
41
-
42
- var e = exec ( 'git pull https://github.com/Hashnode/mern-starter.git' , function ( code , stdout , stderr ) {
43
- clearInterval ( interval ) ;
44
- logUpdate . clear ( ) ;
45
- if ( code !== 0 ) {
46
- console . log ( chalk . red . bold ( 'Error! Try again' ) ) ;
47
- exit ( 1 ) ;
48
- }
49
- console . log ( chalk . green . bold ( 'Completed.....You are good to go!' ) ) ;
50
- } ) ;
27
+ if ( program . args . length === 1 ) {
28
+ if ( test ( '-d' , program . args [ 0 ] ) ) {
29
+ console . log ( chalk . red ( `${ program . args [ 0 ] } directory already exits! Please choose some another name!!!` ) ) ;
30
+ exit ( 1 ) ;
31
+ }
32
+
33
+ mkdir ( '-p' , program . args [ 0 ] ) ;
34
+ cd ( program . args [ 0 ] ) ;
35
+ }
36
+
37
+ exec ( 'git init' ) ;
38
+
39
+ const interval = setInterval ( ( ) => {
40
+ logUpdate ( `Fetching the boilerplate...${ chalk . cyan . bold . dim ( frame ( ) ) } ` ) ;
41
+ } , 50 ) ;
42
+
43
+ exec ( 'git pull https://github.com/Hashnode/mern-starter.git' , ( code ) => {
44
+ clearInterval ( interval ) ;
45
+ logUpdate . clear ( ) ;
46
+ if ( code !== 0 ) {
47
+ console . log ( chalk . red . bold ( 'Error! Try again' ) ) ;
48
+ exit ( 1 ) ;
49
+ }
50
+ console . log ( chalk . green . bold ( 'Completed.....You are good to go!' ) ) ;
51
+ } ) ;
0 commit comments