@@ -13,21 +13,28 @@ const ghURL = 'https://github.com/10up/wp-local-docker.git';
13
13
14
14
export default ( args , config ) => {
15
15
const params = getParams ( args , config ) ;
16
- const promptOpt = prompts . getCreatePrompts ( ) ;
17
- prompts . ask ( promptOpt ) . then ( handlePrompt , e => {
16
+ const promptOpt = prompts . getCreatePrompts ( params ) ;
17
+ const createPromptHandler = ( args , config ) =>
18
+ function ( data ) {
19
+ return handlePrompt ( data , args , config ) ;
20
+ } ;
21
+ prompts . ask ( promptOpt ) . then ( createPromptHandler ( args , config ) , e => {
18
22
log . error ( e . toString ( ) ) ;
19
23
} ) ;
20
24
} ;
21
25
22
26
function getParams ( args , config ) {
23
- const dir = args . dir || '' ;
27
+ const directory = args . directory || '' ;
24
28
return {
25
- dir ,
29
+ directory ,
26
30
} ;
27
31
}
28
32
29
- function handlePrompt ( data ) {
33
+ function handlePrompt ( data , args , config ) {
30
34
try {
35
+ const params = getParams ( args , config ) ;
36
+ data = Object . assign ( data , params ) ;
37
+
31
38
log . info ( 'Checking if directory exist' ) ;
32
39
is_directory_exist ( data . directory ) ;
33
40
@@ -55,12 +62,12 @@ function handlePrompt( data ) {
55
62
return data ;
56
63
}
57
64
58
- function is_directory_exist ( dir ) {
59
- if ( ! dir ) {
65
+ function is_directory_exist ( directory ) {
66
+ if ( ! directory ) {
60
67
throw new Error ( 'We need directory name.' ) ;
61
68
}
62
69
63
- if ( ! fs . emptyDirSync ( dir ) ) {
70
+ if ( ! fs . emptyDirSync ( directory ) ) {
64
71
throw new Error ( 'Directory exist, exit now.' ) ;
65
72
}
66
73
@@ -134,8 +141,10 @@ function installWp( data ) {
134
141
log . info ( wp . install ( data ) ) ;
135
142
}
136
143
137
- function successInfo ( data ) {
138
- log . success ( 'Congratulations! Your local WordPress site now has been created.' ) ;
144
+ function successInfo ( data ) {
145
+ log . success (
146
+ 'Congratulations! Your local WordPress site now has been created.'
147
+ ) ;
139
148
log . success ( 'Url: http://' + data . domain ) ;
140
149
log . success ( 'Username: admin' ) ;
141
150
log . success ( 'Password: password' ) ;
0 commit comments