wild-config
Advanced tools
Comparing version 1.2.2 to 1.2.3
52
index.js
@@ -51,29 +51,33 @@ /* eslint no-console: 0, global-require: 0 */ | ||
if (!stat.isFile()) { | ||
throw new Error('path is not a file'); | ||
throw new Error(filePath + ' is not a file'); | ||
} | ||
let parsed; | ||
try { | ||
let contents = fs.readFileSync(filePath, 'utf-8'); | ||
let contents = fs.readFileSync(filePath, 'utf-8'); | ||
switch (ext) { | ||
case '.js': { | ||
let script = new vm.Script(contents); | ||
const sandbox = { | ||
require, | ||
__dirname: basePath, | ||
__filename: filePath, | ||
module: { | ||
exports: {} | ||
} | ||
}; | ||
script.runInNewContext(sandbox); | ||
parsed = sandbox.module.exports; | ||
break; | ||
switch (ext) { | ||
case '.js': { | ||
let script = new vm.Script(contents); | ||
const sandbox = { | ||
require, | ||
__dirname: basePath, | ||
__filename: filePath, | ||
module: { | ||
exports: {} | ||
} | ||
}; | ||
script.runInNewContext(sandbox); | ||
parsed = sandbox.module.exports; | ||
break; | ||
} | ||
case '.toml': | ||
parsed = tomlParser(basePath, contents); | ||
break; | ||
case '.json': | ||
parsed = JSON.parse(contents); | ||
break; | ||
} | ||
case '.toml': | ||
parsed = tomlParser(basePath, contents); | ||
break; | ||
case '.json': | ||
parsed = JSON.parse(contents); | ||
break; | ||
} catch (E) { | ||
E.message = filePath + ': ' + E.message; | ||
throw E; | ||
} | ||
@@ -132,3 +136,3 @@ return parsed; | ||
// file missing, ignore | ||
console.error(filePath + ': ' + E.message); | ||
console.error('[' + filePath + '] ' + E.message); | ||
process.exit(1); | ||
@@ -135,0 +139,0 @@ } |
{ | ||
"name": "wild-config", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Configuration management module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
14023
247