fileconfig
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -9,2 +9,9 @@ 'use strict' | ||
exports.ComponentNotFound = ComponentNotFound; | ||
class InvalidComponentDefinition extends Error { | ||
constructor(path) { | ||
super('invalid component definition : ' + path); | ||
} | ||
} | ||
exports.ComponentNotFound = ComponentNotFound; | ||
exports.InvalidComponentDefinition = InvalidComponentDefinition; |
@@ -5,3 +5,2 @@ 'use strict' | ||
let Path = require('path'); | ||
let _ = require('underscore'); | ||
@@ -29,3 +28,3 @@ let Resolver = require('./resolver'); | ||
return this.definition.leaf === true | ||
? Object.freeze(_.clone(this.definition.value)) | ||
? Object.freeze(Object.assign({}, this.definition.value, {})) | ||
: FileConfig.fromComponent(this); | ||
@@ -32,0 +31,0 @@ } |
@@ -8,3 +8,4 @@ 'use strict' | ||
let ComponentNotFound = require('./errors').ComponentNotFound; | ||
let ComponentNotFound = require('./errors').ComponentNotFound; | ||
let InvalidComponentDefinition = require('./errors').InvalidComponentDefinition; | ||
@@ -44,5 +45,11 @@ class Vars { | ||
resolve(path) { | ||
let data; | ||
try { | ||
data = this.reader(path); | ||
} catch (error) { | ||
throw new InvalidComponentDefinition(path); | ||
} | ||
return { | ||
path : path | ||
, value : Vars.resolve(this.reader(path)) | ||
, value : Vars.resolve(data) | ||
, leaf : true | ||
@@ -49,0 +56,0 @@ } |
{ | ||
"name": "fileconfig", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "json and yml file configurations", | ||
@@ -11,3 +11,3 @@ "main": "lib/fileconfig.js", | ||
"dev": "./node_modules/.bin/nodemon -e js,json,yml ./node_modules/mocha/bin/mocha --harmony_proxies", | ||
"coverage": "./node_modules/.bin/istanbul cover _mocha -- --recursive && ./node_modules/.bin/istanbul check-coverage", | ||
"coverage": "./node_modules/.bin/istanbul --harmony_proxies cover _mocha -- --recursive && ./node_modules/.bin/istanbul --harmony_proxies check-coverage", | ||
"lint" : "./node_modules/.bin/eslint . --ext .js --debug" | ||
@@ -42,5 +42,4 @@ }, | ||
"jsonfile": "^2.2.3", | ||
"underscore": "^1.8.3", | ||
"yamljs": "^0.2.4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# fileconfig (v-3.1.0) | ||
# fileconfig (v-3.2.0) | ||
@@ -59,2 +59,2 @@ Library for configuration file loading | ||
Apache-2.0 | ||
Apache-2.0 |
@@ -9,3 +9,5 @@ 'use strict' | ||
let ComponentNotFound = require('../lib/errors').ComponentNotFound; | ||
let ComponentNotFound = require('../lib/errors').ComponentNotFound; | ||
let InvalidComponentDefinition = require('../lib/errors').InvalidComponentDefinition; | ||
let FileConfig = require('../lib/fileconfig'); | ||
@@ -88,5 +90,10 @@ let TestConfig = FileConfig.global(); | ||
assert.throws(() => { | ||
let invalid = TestConfig.servers.invalid; | ||
let notfound = TestConfig.servers.notfound; | ||
}, ComponentNotFound); | ||
}); | ||
it('should handle invalid json component definition', () => { | ||
assert.throws(() => { | ||
let invalid = TestConfig.servers.jsonInvalid; | ||
}, InvalidComponentDefinition); | ||
}); | ||
}); |
23269
3
16
263
60
- Removedunderscore@^1.8.3
- Removedunderscore@1.13.7(transitive)