@@ -111,7 +111,7 @@ validators.importBuildFileFromNPM = async function(props) {
111
111
. then ( ( ) => {
112
112
return true ;
113
113
} )
114
- . catch ( async err => {
114
+ . catch ( err => {
115
115
if ( err . code === 1 ) {
116
116
return chalk . red (
117
117
`Sorry, there already seems to be a directory with the same name ${ chalk . cyan (
@@ -145,14 +145,14 @@ validators.importBuildFileFromNPM = async function(props) {
145
145
146
146
validators . copyBuildFileFromNPM = async props => {
147
147
if ( props ) {
148
- var res = executeCommand (
148
+ var res = await executeCommand (
149
149
"cd component-dist && curl -O " + props ,
150
150
"copyBuildFileFromNPM"
151
151
)
152
152
. then ( ( ) => {
153
153
return true ;
154
154
} )
155
- . catch ( async err => {
155
+ . catch ( err => {
156
156
if ( err . code === 3 || err . code === 23 ) {
157
157
return chalk . red (
158
158
"The URL is malformed. Please ensure the URL is in correct format."
@@ -180,21 +180,21 @@ validators.importBuildFileLocally = async props => {
180
180
return true ;
181
181
}
182
182
183
- var res = executeCommand (
183
+ var res = await executeCommand (
184
184
"mkdir component-dist && cp " + props + " component-dist" ,
185
185
"importBuildFileLocally"
186
186
)
187
187
. then ( ( ) => {
188
188
return true ;
189
189
} )
190
- . catch ( async err => {
190
+ . catch ( err => {
191
191
if ( err . code === 1 ) {
192
192
return chalk . red (
193
193
`Oops! We encountered an error. This can happen due to one of the following reasons - \n\n1) The path of build file entered is incorrect. \n2) There's already a directory named ${ chalk . cyan (
194
194
"component-dist"
195
195
) } , in this case please input ${ chalk . cyan (
196
196
"skip"
197
- ) } to paste the build file in your existing directory .\n\nPlease see below for the exact error description - \n${ chalk . yellow (
197
+ ) } to rename the new directory or overwrite files in the existing one .\n\nPlease see below for the exact error description - \n${ chalk . yellow (
198
198
err
199
199
) } `
200
200
) ;
@@ -215,21 +215,60 @@ validators.importBuildFileLocally = async props => {
215
215
return chalk . red ( "This is a mandatory field, please answer." ) ;
216
216
} ;
217
217
218
- validators . copyBuildFileLocally = async props => {
218
+ validators . renameDirectory = async props => {
219
+ if ( props ) {
220
+ var res = await executeCommand ( "mkdir " + props )
221
+ . then ( ( ) => true )
222
+ . catch ( err => {
223
+ return chalk . red (
224
+ "Oops! We encountered an error, please see the log below for more details.\n" +
225
+ err
226
+ ) ;
227
+ } ) ;
228
+ return res ;
229
+ /**
230
+ * Returns true if command execution is successful and proceeds to commonPrompts
231
+ * returns and logs the error if execution fails
232
+ */
233
+ }
234
+
235
+ return chalk . red ( "This is a mandatory field, please answer." ) ;
236
+ } ;
237
+
238
+ validators . importBuildFileInRenamedDirectory = async ( props , answers ) => {
219
239
if ( props ) {
220
- var res = executeCommand (
221
- "cp " + props + " component-dist" ,
222
- "copyBuildFileLocally"
240
+ var res = await executeCommand (
241
+ "cp " + props + " " + answers . renameDirectory
223
242
)
224
- . then ( ( ) => {
225
- return true ;
226
- } )
227
- . catch ( async err => {
243
+ . then ( ( ) => true )
244
+ . catch ( err => {
228
245
return chalk . red (
229
246
"Oops! We encountered an error, please see the log below for more details.\n" +
230
247
err
231
248
) ;
232
- } ) ; // Import the build file in component-dist directory locally from computer
249
+ } ) ;
250
+ return res ;
251
+ /**
252
+ * Returns true if command execution is successful and proceeds to commonPrompts
253
+ * returns and logs the error if execution fails
254
+ */
255
+ }
256
+
257
+ return chalk . red ( "This is a mandatory field, please answer." ) ;
258
+ } ;
259
+
260
+ validators . overwriteDirectoryContent = async props => {
261
+ if ( props ) {
262
+ var res = await executeCommand (
263
+ "rm -rf component-dist/* && cp " + props + " component-dist"
264
+ )
265
+ . then ( ( ) => true )
266
+ . catch ( err => {
267
+ return chalk . red (
268
+ "Oops! We encountered an error, please see the log below for more details.\n" +
269
+ err
270
+ ) ;
271
+ } ) ;
233
272
return res ;
234
273
/**
235
274
* Returns true if command execution is successful and proceeds to commonPrompts
0 commit comments