Skip to content

Commit

Permalink
fix: make no-pattern error print correctly
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
xz64 committed Dec 18, 2016
1 parent 16c6b59 commit 28f1e1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ var instance = function() {

var licensePlugin = function(opts) {
if(!opts || !opts.pattern || !(opts.pattern instanceof RegExp)) {
this.errors.push(plugin.errorMessages['no-pattern']);
throw plugin.errorMessages['no-pattern'];
throw new Error(plugin.errorMessages['no-pattern']);
}
objectAssign(this, composedPlugin, instance(), opts);
this.apply = this.apply.bind(this);
Expand Down
6 changes: 6 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,5 +566,11 @@ test('plugin', function (t) {
t.end();
});

t.test('the plugin throws a descriptive error when no pattern is specified',
function(t) {
t.throws(createPlugin.bind(null, {}));
t.end();
});

t.end();
});

0 comments on commit 28f1e1d

Please sign in to comment.