confidence
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "confidence", | ||
"description": "Configuration API", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"repository": "git://github.com/hapijs/confidence", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -276,6 +276,42 @@ ![confidence Logo](https://raw.github.com/spumko/con/master/images/confidence.png) | ||
In this case, when requesting `/` with the criteria of `{ "env" : "production" }`, you will receive `{ "logLevel": "error", "logLocation": "/logs" }`. However when requesting it with the criteria `{ "env": "staging" }`, it will return `{ "logLevel": "debug", "logLocation": "/logs" }`. | ||
When requesting the **key** `/` with: | ||
In the case that the same key occurs in `$base` and the filtered value the value in `$base` will be overridden. In the above sample, `/` requested with `{ "env": "qa" }` will return `{ "logLevel": "info", "logLocation": "/qa/logs" }` | ||
* **criteria** of `{ "env" : "production" }` | ||
* Result will be: | ||
```json | ||
{ | ||
"logLevel": "error", | ||
"logLocation": "/logs" | ||
} | ||
``` | ||
However when requesting the **key** `/` with: | ||
* **criteria** of `{ "env" : "staging" }` | ||
* Result will be: | ||
```json | ||
{ | ||
"logLevel": "debug", | ||
"logLocation": "/logs" | ||
} | ||
``` | ||
If the same key occurs in `$base` and the `filtered value` then value in `$base` will be overridden. | ||
In the above sample, when requesting the **key** `/` with: | ||
* **criteria** of `{ "env": "qa" }` | ||
* Result will be: | ||
```json | ||
{ | ||
"logLevel": "info", | ||
"logLocation": "/qa/logs" | ||
} | ||
``` | ||
# API | ||
@@ -282,0 +318,0 @@ |
@@ -131,1 +131,37 @@ // Load modules | ||
}); | ||
it('generates the correct config with custom indentation', function (done) { | ||
var confidence = ChildProcess.spawn('node', [confidencePath, '-c', configPath, '--filter.env', 'production', '-i', 2]); | ||
confidence.stdout.on('data', function (data) { | ||
var result = data.toString(); | ||
var obj = JSON.parse('{"key1":"abc","key2":{"deeper":"value"},"key3":{"sub1":0},"key4":[12,13,14],"key5":{},"ab":6}'); | ||
expect(result).to.equal(JSON.stringify(obj, null, 2)); | ||
confidence.kill(); | ||
done(); | ||
}); | ||
confidence.stderr.on('data', function (data) { | ||
expect(data.toString()).to.not.exist(); | ||
}); | ||
}); | ||
it('fails when custom indentation is not a number', function (done) { | ||
var confidence = ChildProcess.spawn('node', [confidencePath, '-c', configPath, '--filter.env', 'production', '-i', 'someString']); | ||
confidence.stdout.on('data', function (data) { | ||
expect(data.toString()).to.not.exist(); | ||
}); | ||
confidence.stderr.on('data', function (data) { | ||
expect(data.toString()).to.exist(); | ||
}); | ||
confidence.on('close', function () { | ||
done(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
85026
937
382