dsl-config
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "dsl-config", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Generate a DSL config with generators", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -74,15 +74,18 @@ 'use strict'; | ||
// to the config | ||
if (defaultValue) { | ||
const clone = new DSLConfig(dslConfig); | ||
this.config[name] = clone.config; | ||
} | ||
this.dsl[name] = function(callback) { | ||
const clone = new DSLConfig(dslConfig); | ||
this.config[name] = clone.config; | ||
const promise = configureDsl(clone.dsl, callback); | ||
if (isPromise(promise)) { | ||
return promise.then(() => this.dsl); | ||
this.dsl[name] = (function() { | ||
let clone; | ||
if (defaultValue) { | ||
clone = new DSLConfig(dslConfig); | ||
this.config[name] = clone.config; | ||
} | ||
return this.dsl; | ||
}; | ||
return function(callback) { | ||
clone = clone || new DSLConfig(dslConfig); | ||
this.config[name] = clone.config; | ||
const promise = configureDsl(clone.dsl, callback); | ||
if (isPromise(promise)) { | ||
return promise.then(() => this.dsl); | ||
} | ||
return this.dsl; | ||
}; | ||
}).bind(this)(); | ||
} | ||
@@ -89,0 +92,0 @@ return this; |
@@ -335,2 +335,21 @@ 'use strict'; | ||
it('should accumulate on subsequent calls', () => { | ||
dslConfig.configure(config => { | ||
config | ||
.sub1(sub1 => { | ||
sub1 | ||
.sub1value1('value1'); | ||
}) | ||
.sub1(sub1 => { | ||
sub1 | ||
.sub1value2('value2'); | ||
}); | ||
}).should.eql({ | ||
sub1: { | ||
sub1value1: 'value1', | ||
sub1value2: 'value2' | ||
} | ||
}); | ||
}); | ||
it('should throw if the callback throws', () => { | ||
@@ -337,0 +356,0 @@ (() => { |
53902
1586