Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not init wildcard booleans #4

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ script:

after_success:
- npm install istanbul codecov
- npm run coverage
- npm run cover
- ./node_modules/.bin/codecov

sudo: false
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

# 1.0.4 - 2016-10-25

* do not leave behind a `*` section in config (due to wildcard boolean)

# 1.0.3

* added wildcard boolean support
* reduce node required 4.3 -> 0.10.43
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
"scripts": {
"test": "./run_tests",
"lint": "./node_modules/.bin/grunt lint",
"coverage": "./node_modules/.bin/istanbul cov run_tests"
"cover": "./node_modules/.bin/istanbul cov run_tests"
}
}
2 changes: 2 additions & 0 deletions readers/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ exports.init_booleans = function (options, result) {
if (section.match(/^(\-|\+)/)) section = section.substr(1);
if ( key.match(/^(\-|\+)/)) key = key.substr(1);

if (section === '*') continue; // wildcard, don't initialize

// so boolean detection in the next section will match
if (options.booleans.indexOf(section + '.' + key) === -1) {
this.bool_matches.push(section + '.' + key);
Expand Down
15 changes: 11 additions & 4 deletions test/readers/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ exports.load = {
'test.ini, sect1, opts, w/defaults' : function (test) {
test.expect(6);
var r = this.ini.load('test/config/test.ini', {
booleans: ['+sect1.bool_true','-sect1.bool_false',
'+sect1.bool_true_default', 'sect1.-bool_false_default']
booleans: [
'+sect1.bool_true',
'-sect1.bool_false',
'+sect1.bool_true_default',
'sect1.-bool_false_default'
]
}, regex);
test.strictEqual(r.sect1.bool_true, true);
test.strictEqual(r.sect1.bool_false, false);
Expand All @@ -77,10 +81,13 @@ exports.load = {
test.done();
},
'test.ini, wildcard boolean' : function (test) {
test.expect(2);
test.expect(5);
var r = this.ini.load('test/config/test.ini', {
booleans: [ '*.is_bool' ]
booleans: [ '+main.bool_true', '*.is_bool' ]
}, regex);
test.strictEqual(r['*'], undefined);
test.strictEqual(r.main.bool_true, true);
test.strictEqual(r.main.is_bool, undefined);
test.strictEqual(r['foo.com'].is_bool, true);
test.strictEqual(r['bar.com'].is_bool, false);
test.done();
Expand Down