Skip to content

Commit

Permalink
feat(config): improve config "inheritance"
Browse files Browse the repository at this point in the history
allow extended configs to extend configs themselves
  • Loading branch information
dmbch committed Jan 25, 2018
1 parent b9519cd commit 7ba54ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ function getDefaultConfig() {

function applyUserConfig(config) {
var result = explorer.load(process.cwd());
return assign(config, result ? result.config : {});
return assign({}, config, result ? result.config : {});
}

function applyExtensionConfig(config) {
function applyInheritedConfig(config) {
var result = Object.assign({}, config);
if (config.extends) {
delete result.extends;
try {
require.resolve(config.extends);
assign(result, require(config.extends));
Expand All @@ -48,7 +49,7 @@ function applyExtensionConfig(config) {
}
}
}
return result;
return result.extends ? applyInheritedConfig(result) : result;
}

function applyEnvironmentConfig(config) {
Expand Down Expand Up @@ -102,7 +103,7 @@ function normalizeURLs(config) {
module.exports = [
getDefaultConfig,
applyUserConfig,
applyExtensionConfig,
applyInheritedConfig,
applyEnvironmentConfig,
resolvePaths,
normalizeURLs,
Expand Down

0 comments on commit 7ba54ae

Please sign in to comment.