Comparing version 0.1.0 to 0.1.1
@@ -8,2 +8,10 @@ # Confort Changelog | ||
## [v0.1.1] - 2019-09-23 | ||
### Added | ||
- support to CSON file type | ||
### Changed | ||
- layering to merge objects recursively instead of shallow replacing the keys | ||
## [v0.1.0] - 2019-07-30 | ||
@@ -13,1 +21,2 @@ - First officially published version. | ||
[v0.1.0]: https://gitlab.com/GCSBOSS/confort/-/tags/v0.1.0 | ||
[v0.1.1]: https://gitlab.com/GCSBOSS/confort/-/tags/v0.1.1 |
@@ -6,2 +6,3 @@ | ||
const YAML = require('yaml'); | ||
const CSON = require('cson-parser'); | ||
const assert = require('assert'); | ||
@@ -12,3 +13,4 @@ | ||
yaml: conf => YAML.parse(fs.readFileSync(conf, 'utf8')), | ||
json: conf => JSON.parse(fs.readFileSync(conf, 'utf8')) | ||
json: conf => JSON.parse(fs.readFileSync(conf, 'utf8')), | ||
cson: conf => CSON.parse(fs.readFileSync(conf, 'utf8')) | ||
} | ||
@@ -15,0 +17,0 @@ |
const fs = require('fs'); | ||
const assert = require('assert'); | ||
const deepmerge = require('deepmerge'); | ||
const EventEmitter = require('events'); | ||
@@ -46,3 +47,5 @@ const loadConf = require('./conf-loader'); | ||
this.object = { ...this.object, ...pathOrObject }; | ||
this.object = deepmerge(this.object, pathOrObject, { | ||
arrayMerge: (a, b) => b | ||
}); | ||
@@ -49,0 +52,0 @@ setupWatches.bind(this)(); |
{ | ||
"name": "confort", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A library for incrementally build config objects through layering config files in many formats.", | ||
@@ -33,2 +33,4 @@ "main": "lib/main.js", | ||
"dependencies": { | ||
"cson-parser": "^4.0.2", | ||
"deepmerge": "^4.0.0", | ||
"toml": "^3.0.0", | ||
@@ -35,0 +37,0 @@ "yaml": "^1.6.0" |
@@ -6,7 +6,7 @@ # [Confort](https://gitlab.com/GCSBOSS/confort) | ||
- Support native objects directly | ||
- Support native objects input directly | ||
- Load config files | ||
- Merge configs chronologically | ||
- Option to watch changes in loaded config files | ||
- Supported formats so far: TOML, JSON and YAML | ||
- Supported formats so far: TOML, JSON, CSON and YAML | ||
@@ -13,0 +13,0 @@ ## Get Started |
@@ -33,2 +33,7 @@ const fs = require('fs'); | ||
}); | ||
it('Should properly load an CSON file and generate an object', () => { | ||
let obj = loadConf('./test/res/conf.cson'); | ||
assert.strictEqual(obj.key, 'value'); | ||
}); | ||
}); | ||
@@ -68,2 +73,10 @@ | ||
it('Should merge objects instead of just replacing', () => { | ||
let conf = new Confort({ key: { a: 'b', e: [ 0 ] } }); | ||
conf.addLayer({ key: { c: 'd', e: [ 1 ] } }); | ||
assert.strictEqual(conf.object.key.a, 'b'); | ||
assert.strictEqual(conf.object.key.c, 'd'); | ||
assert.strictEqual(conf.object.key.e[0], 1); | ||
}); | ||
it('Should load conf file when path is specified', () => { | ||
@@ -70,0 +83,0 @@ let conf = new Confort('./test/res/conf.toml'); |
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
16730
15
232
4
+ Addedcson-parser@^4.0.2
+ Addeddeepmerge@^4.0.0
+ Addedcoffeescript@1.12.7(transitive)
+ Addedcson-parser@4.0.9(transitive)
+ Addeddeepmerge@4.3.1(transitive)