Comparing version 0.7.1 to 0.8.0
26
index.js
@@ -51,11 +51,19 @@ "use strict"; | ||
function load(appName, opts) { | ||
const ignoreUnknownFormats = | ||
(opts != null && opts.ignoreUnknownFormats) || false; | ||
function load( | ||
appName, | ||
{ | ||
appDir = DEFAULT_APP_DIR, | ||
defaults, | ||
entries: whitelist, | ||
ignoreUnknownFormats = false, | ||
} = {} | ||
) { | ||
const useWhitelist = whitelist !== undefined; | ||
if (useWhitelist) { | ||
whitelist = new Set(whitelist); | ||
} | ||
return pMap(entries, entry => | ||
entry.read({ | ||
appDir: (opts && opts.appDir) || DEFAULT_APP_DIR, | ||
appName, | ||
}) | ||
useWhitelist && !whitelist.has(entry.name) | ||
? [] | ||
: entry.read({ appDir, appName }) | ||
) | ||
@@ -82,3 +90,3 @@ .then(files => { | ||
return acc; | ||
}, merge({}, opts && opts.defaults)) | ||
}, merge({}, defaults)) | ||
); | ||
@@ -85,0 +93,0 @@ } |
{ | ||
"name": "app-conf", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "Julien Fontanet <julien.fontanet@isonoe.net> (http://julien.isonoe.net/)", |
@@ -7,13 +7,2 @@ # app-conf | ||
```javascript | ||
var loadConfig = require("app-conf").load; | ||
loadConfig("my-application", { | ||
// this is the directory where the vendor conf is stored | ||
appDir: __dirname, | ||
}).then(function(config) { | ||
console.log(config); | ||
}); | ||
``` | ||
The following files are looked up and merged (the latest take | ||
@@ -31,2 +20,22 @@ precedence): | ||
```javascript | ||
var loadConfig = require("app-conf").load; | ||
loadConfig("my-application", { | ||
// this is the directory where the vendor conf is stored | ||
appDir: __dirname, | ||
// default config values | ||
defaults: {}, | ||
// which types of config should be loaded | ||
entries: ["vendor", "global", "user", "local"], | ||
// whether to ignore unknown file formats instead of throwing | ||
ignoreUnknownFormats: false, | ||
}).then(function(config) { | ||
console.log(config); | ||
}); | ||
``` | ||
Relative paths, string values starting by `./` or `../`, are automatically | ||
@@ -33,0 +42,0 @@ resolved from the config file directory. |
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
12769
277
68