Skip to content

Commit 256df62

Browse files
Merge pull request #12 from explore-node-js/master
sync with main repository
2 parents cc1d06b + 6766549 commit 256df62

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-parameter-handler",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "build JSON files which can be used as settings",
55
"main": "index.js",
66
"repository": {

src/processor.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs');
22
const deepmerge = require('deepmerge');
33
const File = require('./file');
4+
const chalk = require('chalk')
45
const overwriteFieldValue = require('node-object-field-resolver');
56

67
module.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

Comments
 (0)