@@ -37,47 +37,43 @@ function _parseInputFromUser (callback) {
37
37
. option ( '-t, --template <location>' , 'specify input template location' , templateFileLocation . yaml )
38
38
. parse ( process . argv )
39
39
40
- var initArgs = program . args
41
-
42
- if ( initArgs . length < 1 ) {
43
- callback ( 'Filename required. Please specify a valid' + suppFileExtns . join ( '/' ) + 'template location as argument.' , null )
40
+ if ( program . args . length < 1 ) {
41
+ callback ( 'Please specify a valid filename for plan output.' , null )
44
42
}
45
43
44
+ var destFilePath = program . args [ 0 ]
45
+
46
46
if ( utils . fileExists ( program . template ) === false ) {
47
- callback ( 'Please specify a valid' + suppFileExtns . join ( '/' ) + ' template file location.', null )
47
+ callback ( 'Please specify a valid template file location.' , null )
48
48
}
49
49
50
- let fileExt = path . extname ( program . template )
50
+ var fileExt = path . extname ( program . template )
51
51
52
52
if ( suppFileExtns . indexOf ( fileExt ) === - 1 ) {
53
- callback ( 'File extension not supported. Please use supported file extensions: ' + suppFileExtns . join ( ', ' ) , null )
53
+ callback ( 'Template extension not supported. Please use supported file extensions: ' + suppFileExtns . join ( ', ' ) , null )
54
54
} else {
55
- callback ( null , program . template , initArgs )
55
+ callback ( null , program . template , destFilePath )
56
56
}
57
57
}
58
58
59
- function _getOptsFromUser ( templateFilePath , initArgs , callback ) {
60
- var destFilePath = initArgs [ 0 ]
59
+ function _getOptsFromUser ( templateFilePath , destFilePath , callback ) {
61
60
if ( utils . fileExists ( destFilePath ) ) {
62
61
rl . question ( 'File already exists. Do you want to overwrite this file? [N/y]' , function ( answer ) {
63
62
if ( userOptsYes . indexOf ( answer ) === - 1 ) {
64
63
callback ( 'Not overwriting the file: ' + destFilePath + '. Create plan file with new name and try again.' , null )
65
64
}
66
- callback ( null , templateFilePath , initArgs )
65
+ callback ( null , templateFilePath , destFilePath )
67
66
} )
68
67
} else {
69
- callback ( null , templateFilePath , initArgs )
68
+ callback ( null , templateFilePath , destFilePath )
70
69
}
71
70
}
72
71
73
- function _copyTemplateFile ( templateFilePath , initArgs , callback ) {
74
- var destFilePath = initArgs [ 0 ]
75
- initArgs . forEach ( function ( initArg ) {
76
- try {
77
- fs . copySync ( templateFilePath , destFilePath )
78
- } catch ( err ) {
79
- callback ( err , 'Error copying to the file: ' + destFilePath )
80
- }
81
- callback ( null , 'Plan file copied successfully: ' + destFilePath )
82
- } )
72
+ function _copyTemplateFile ( templateFilePath , destFilePath , callback ) {
73
+ try {
74
+ fs . copySync ( templateFilePath , destFilePath )
75
+ } catch ( err ) {
76
+ callback ( err , 'Error copying to the file: ' + destFilePath )
77
+ }
78
+ callback ( null , 'Plan file copied successfully: ' + destFilePath )
83
79
}
0 commit comments