Skip to content

Commit

Permalink
fix(config): fix config extension mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbch committed Feb 5, 2018
1 parent 10c1dd7 commit fcc1a74
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions packages/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ var root = require('pkg-dir').sync();

var cosmiconfig = require('cosmiconfig');

function getDefaultConfig() {
return {
https: false,
host: '0.0.0.0',
port: 8080,
locations: [],
basePath: '',
assetPath: '',
browsers: '> 1%, last 2 versions, Firefox ESR',
node: 'current',
envVars: { HOPS_MODE: 'dynamic' },
moduleDirs: [],
appDir: '.',
buildDir: 'build',
cacheDir: 'node_modules/.cache/hops',
};
function applyDefaultConfig(config) {
return assign(
{
https: false,
host: '0.0.0.0',
port: 8080,
locations: [],
basePath: '',
assetPath: '',
browsers: '> 1%, last 2 versions, Firefox ESR',
node: 'current',
envVars: { HOPS_MODE: 'dynamic' },
moduleDirs: [],
appDir: '.',
buildDir: 'build',
cacheDir: 'node_modules/.cache/hops',
},
config
);
}

function applyUserConfig(config) {
Expand Down Expand Up @@ -53,7 +56,7 @@ function applyInheritedConfig(config) {
sync: true,
});
var _result = loader.load();
assign(result, assign(_result ? _result.config : {}, result));
result = assign(_result ? _result.config : {}, result);
} else {
console.error('Failed to load inherited config', configName);
}
Expand Down Expand Up @@ -126,13 +129,13 @@ function normalizeURLs(config) {
}

module.exports = [
getDefaultConfig,
applyUserConfig,
applyInheritedConfig,
applyEnvironmentConfig,
applyDefaultConfig,
resolvePlaceholders,
resolvePaths,
normalizeURLs,
].reduce(function(result, step) {
return step(result);
}, null);
}, {});

0 comments on commit fcc1a74

Please sign in to comment.