Comparing version 0.1.7 to 0.1.8
@@ -124,23 +124,27 @@ /*! | ||
* Open a config file. | ||
* @param {String} file - e.g. `bcoin.conf`. | ||
* @param {String|String[]} file - e.g. `bcoin.conf`, or array of strings | ||
* @throws on IO error | ||
*/ | ||
open(file) { | ||
open(files) { | ||
if (fs.unsupported) | ||
return; | ||
const path = this.getFile(file); | ||
files = !Array.isArray(files) ? [files] : files; | ||
let text; | ||
try { | ||
text = fs.readFileSync(path, 'utf8'); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') | ||
return; | ||
throw e; | ||
for (const file of files) { | ||
const path = this.getFile(file); | ||
let text; | ||
try { | ||
text = fs.readFileSync(path, 'utf8'); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') | ||
continue; | ||
throw e; | ||
} | ||
this.parseConfig(text); | ||
} | ||
this.parseConfig(text); | ||
this.prefix = this.getPrefix(); | ||
@@ -152,8 +156,26 @@ } | ||
* @param {String} name | ||
* @param {Object} [inheritFiltered={}] | ||
* @param {Boolean} [inheritFiltered.env=true] | ||
* @param {Boolean} [inheritFiltered.args=true] | ||
* @param {Boolean} [inheritFiltered.query=true] | ||
* @param {Boolean} [inheritFiltered.hash=true] | ||
* @param {Boolean} [inheritFiltered.options=true] | ||
* @param {Boolean} [inheritFiltered.data=false] | ||
* @returns {Config} | ||
*/ | ||
filter(name) { | ||
filter(name, inheritFiltered = {}) { | ||
assert(typeof name === 'string'); | ||
// Defaults. | ||
const inherit = { | ||
env: true, | ||
args: true, | ||
query: true, | ||
hash: true, | ||
options: true, | ||
data: false, | ||
...inheritFiltered | ||
}; | ||
const child = new Config(this.module); | ||
@@ -167,8 +189,20 @@ | ||
_filter(name, this.env, child.env); | ||
_filter(name, this.args, child.args); | ||
_filter(name, this.query, child.query); | ||
_filter(name, this.hash, child.hash); | ||
_filter(name, this.options, child.options); | ||
if (inherit.env) | ||
_filter(name, this.env, child.env); | ||
if (inherit.args) | ||
_filter(name, this.args, child.args); | ||
if (inherit.query) | ||
_filter(name, this.query, child.query); | ||
if (inherit.hash) | ||
_filter(name, this.hash, child.hash); | ||
if (inherit.options) | ||
_filter(name, this.options, child.options); | ||
if (inherit.data) | ||
_filter(name, this.data, child.data); | ||
return child; | ||
@@ -175,0 +209,0 @@ } |
{ | ||
"name": "bcfg", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Config parser for bcoin", | ||
@@ -18,3 +18,3 @@ "keywords": [ | ||
"scripts": { | ||
"lint": "eslint lib/ || exit 0", | ||
"lint": "eslint lib/", | ||
"test": "bmocha --reporter spec test/*-test.js" | ||
@@ -21,0 +21,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
182117
16
4312
2