@@ -28,7 +28,7 @@ const template = program.args[0];
28
28
const templateArgs = program . args . slice ( 1 ) ;
29
29
30
30
let templatePath = `${ cwd } /.lazy/templates/${ template } ` ;
31
- let templateSettings = JSON . parse ( fs . readFileSync ( `${ templatePath } /template-settings.json` ) ) ;
31
+ let templateSettings = require ( `${ templatePath } /template-settings.js` ) ;
32
32
33
33
if ( templateArgs . lentgh < templateSettings . inputs . length ) {
34
34
console . error ( ' ERROR - Missing template arguments' ) ;
@@ -50,12 +50,18 @@ for (let key in templateSettings.inputs) {
50
50
let outputs = { } ;
51
51
for ( let file in templateSettings . outputs ) {
52
52
let output = templateSettings . outputs [ file ] ;
53
-
54
- for ( let input in inputs ) {
55
- output = output . replace ( `%{${ input } }` , inputs [ input ] ) ;
53
+ let outputPath = '' ;
54
+
55
+ if ( typeof output == 'function' ) {
56
+ outputPath = output ( inputs ) ;
57
+ } else {
58
+ outputPath = output ;
59
+ for ( let input in inputs ) {
60
+ outputPath = outputPath . replace ( `%{${ input } }` , inputs [ input ] ) ;
61
+ }
56
62
}
57
63
58
- outputs [ file ] = output ;
64
+ outputs [ file ] = outputPath ;
59
65
}
60
66
61
67
for ( let file in outputs ) {
@@ -80,6 +86,11 @@ for (let file in outputs) {
80
86
Object . assign ( templateParams , { path, outputs} ) ;
81
87
Object . assign ( templateParams , inputs ) ;
82
88
89
+ if ( fs . existsSync ( `${ cwd } /${ output } ` ) ) {
90
+ console . log ( ` Destination file already exists, skiping...` ) ;
91
+ continue ;
92
+ }
93
+
83
94
consolidate [ lazySettings . engine ] ( `${ templatePath } /${ file } ` , templateParams , ( err , result ) => {
84
95
if ( err ) throw err ;
85
96
0 commit comments