@untool/core
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="0.5.0"></a> | ||
# [0.5.0](https://github.com/untool/untool/compare/v0.4.3...v0.5.0) (2018-05-07) | ||
### Bug Fixes | ||
* update dependency cosmiconfig to v5 ([dc20aaf](https://github.com/untool/untool/commit/dc20aaf)) | ||
<a name="0.4.3"></a> | ||
@@ -8,0 +19,0 @@ ## [0.4.3](https://github.com/untool/untool/compare/v0.4.2...v0.4.3) (2018-04-24) |
@@ -22,10 +22,6 @@ const { basename, dirname, join } = require('path'); | ||
const resolvePreset = (context, preset) => { | ||
try { | ||
return createResolver({ | ||
mainFiles: ['preset'], | ||
mainFields: ['preset'], | ||
})(context, preset); | ||
} catch (_) { | ||
throw new Error(`preset not found ${preset}`); | ||
} | ||
return createResolver({ | ||
mainFiles: ['preset'], | ||
mainFields: ['preset'], | ||
})(context, preset); | ||
}; | ||
@@ -62,11 +58,7 @@ | ||
const nsp = process.env.UNTOOL_NSP || 'untool'; | ||
try { | ||
const options = preset | ||
? { configPath: resolvePreset(context, preset), sync: true } | ||
: { rcExtensions: true, stopDir: context, sync: true }; | ||
const explorer = cosmiconfig(nsp, options); | ||
return applyEnv(explorer.load(context)); | ||
} catch (_) { | ||
return null; | ||
} | ||
const explorer = cosmiconfig(nsp, { cache: false, stopDir: context }); | ||
const presetPath = preset && resolvePreset(context, preset); | ||
return applyEnv( | ||
presetPath ? explorer.loadSync(presetPath) : explorer.searchSync(context) | ||
); | ||
}; | ||
@@ -79,19 +71,22 @@ | ||
const loadPreset = (context, preset) => { | ||
try { | ||
return loadConfig(context, preset); | ||
} catch (_) { | ||
return loadConfig( | ||
dirname(resolvePreset(context, `${preset}/package.json`)) | ||
); | ||
} | ||
}; | ||
const loadPresets = (context, presets = []) => | ||
presets.reduce((result, preset) => { | ||
const loadedConfig = | ||
loadConfig(context, preset) || | ||
loadConfig(dirname(resolvePreset(context, join(preset, 'package.json')))); | ||
if (loadedConfig) { | ||
const { config, filepath } = loadedConfig; | ||
const newContext = dirname(filepath); | ||
if (config.mixins) { | ||
config.mixins = config.mixins.map( | ||
mixin => (mixin.startsWith('.') ? join(newContext, mixin) : mixin) | ||
); | ||
} | ||
return merge(result, loadPresets(newContext, config.presets), config); | ||
} else { | ||
throw new Error(`preset not found: ${preset}`); | ||
presets.reduce((configs, preset) => { | ||
const { config, filepath } = loadPreset(context, preset); | ||
const newContext = dirname(filepath); | ||
if (config.mixins) { | ||
config.mixins = config.mixins.map( | ||
mixin => (mixin.startsWith('.') ? join(newContext, mixin) : mixin) | ||
); | ||
} | ||
return merge(configs, loadPresets(newContext, config.presets), config); | ||
}, {}); | ||
@@ -98,0 +93,0 @@ |
{ | ||
"name": "@untool/core", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "untool core", | ||
@@ -24,3 +24,3 @@ "main": "lib/core.js", | ||
"dependencies": { | ||
"cosmiconfig": "^4.0.0", | ||
"cosmiconfig": "^5.0.1", | ||
"enhanced-resolve": "^4.0.0", | ||
@@ -27,0 +27,0 @@ "find-up": "^2.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15686
165
+ Addedcaller-callsite@2.0.0(transitive)
+ Addedcaller-path@2.0.0(transitive)
+ Addedcallsites@2.0.0(transitive)
+ Addedcosmiconfig@5.2.1(transitive)
+ Addedimport-fresh@2.0.0(transitive)
+ Addedresolve-from@3.0.0(transitive)
- Removedcosmiconfig@4.0.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
Updatedcosmiconfig@^5.0.1