Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config don't check LISK_NETWORK env variable - Closes #2437 #2440

Merged
merged 1 commit into from Oct 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/update_config.js
Expand Up @@ -28,6 +28,12 @@ const applyChange = require('deep-diff').applyChange;

const rootPath = path.resolve(path.dirname(__filename), '../');
const loadJSONFile = filePath => JSON.parse(fs.readFileSync(filePath), 'utf8');
const loadJSONFileIfExists = filePath => {
if (fs.existsSync(filePath)) {
return JSON.parse(fs.readFileSync(filePath), 'utf8');
}
return {};
};
let oldConfigPath;
let newConfigPath;

Expand Down Expand Up @@ -59,13 +65,18 @@ if (oldConfig.ssl) {
}

// New config in 1.1.x will be partial config other than default/config.json
const newConfig = loadJSONFile(newConfigPath);
const newConfig = loadJSONFileIfExists(newConfigPath);

// Now get a unified config.json for 1.1.x version
const defaultConfig = loadJSONFile(
path.resolve(rootPath, 'config/default/config.json')
);
const unifiedNewConfig = merge({}, defaultConfig, newConfig);

const networkConfig = loadJSONFileIfExists(
path.resolve(rootPath, `config/${process.env.LISK_NETWORK}/config.json`)
);

const unifiedNewConfig = merge({}, defaultConfig, networkConfig, newConfig);

const changesMap = {
N: ' Added',
Expand Down Expand Up @@ -125,7 +136,7 @@ observableDiff(oldConfig, unifiedNewConfig, d => {
// now we need to extract differences from default config file
// to write those in network specific directory
const customConfig = {};
observableDiff(defaultConfig, oldConfig, d => {
observableDiff(unifiedNewConfig, oldConfig, d => {
applyChange(customConfig, oldConfig, d);
});

Expand Down