11const fs = require ( 'fs' ) ;
22const deepmerge = require ( 'deepmerge' ) ;
33const File = require ( './file' ) ;
4+ const chalk = require ( 'chalk' )
45const overwriteFieldValue = require ( 'node-object-field-resolver' ) ;
56
67module . exports = class Processor {
@@ -11,22 +12,30 @@ module.exports = class Processor {
1112
1213 process ( ) {
1314 this . files = [ ] ;
15+ console . log ( chalk . yellow ( `>>> PROCESSING FILES` ) ) ;
1416
1517 this . config . forEach ( config => {
1618 let file = this . processFile ( config ) ;
1719
1820 this . files . push ( file ) ;
21+ console . log ( chalk . yellow ( `>>>>> ${ file . getSourcePath ( ) } ` ) ) ;
1922 } )
2023 }
2124
2225 write ( ) {
23- this . files . forEach ( file => fs . writeFile ( file . getOutputPath ( ) , JSON . stringify ( file . getContent ( ) , null , 2 ) , 'UTF-8' ) ) ;
26+ console . log ( chalk . green ( `>>> WRITING FILES` ) ) ;
27+
28+ this . files . forEach ( file => {
29+ console . log ( chalk . green ( `>>>>> ${ file . getOutputPath ( ) } ` ) ) ;
30+
31+ fs . writeFile ( file . getOutputPath ( ) , JSON . stringify ( file . getContent ( ) , null , 2 ) , 'UTF-8' )
32+ } ) ;
2433 }
2534
2635 /**
27- * @param {{envMap: {}, output : string, source : string} } config
36+ * @param {{envMap: {}, source : string, output : string} } config
2837 *
29- * @returns {* }
38+ * @returns {File }
3039 */
3140 processFile ( config ) {
3241 const file = new File ( ) ;
@@ -63,12 +72,12 @@ module.exports = class Processor {
6372 resolveOverwritten ( envMapping ) {
6473 const object = { } ;
6574
66- for ( const abstractPath of Object . keys ( envMapping ) ) {
75+ Object . keys ( envMapping ) . forEach ( abstractPath => {
6776 const envVariable = envMapping [ abstractPath ] ;
6877 const value = this . constructor . getEnvironmentValue ( envVariable ) ;
6978
7079 overwriteFieldValue ( abstractPath , value , object ) ;
71- }
80+ } ) ;
7281
7382 return object ;
7483 }
0 commit comments