Skip to content

Commit

Permalink
Merge pull request #319 from tleunen/patch-transform
Browse files Browse the repository at this point in the history
Removes array test for transform and plugin
  • Loading branch information
tleunen committed Mar 11, 2016
2 parents f58b406 + f310895 commit 2d41265
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
14 changes: 2 additions & 12 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,13 @@ GruntBrowserifyRunner.prototype = _.create(GruntBrowserifyRunner.prototype, {

if (options.transform) {
_.forEach(options.transform, function (transformer) {
if (typeof transformer !== 'object') {
b.transform(transformer);
}
else {
b.transform(transformer[1], transformer[0]);
}
b.transform(transformer);
});
}

if (options.plugin) {
_.forEach(options.plugin, function (plugin) {
if (typeof plugin !== 'object') {
b.plugin(plugin);
}
else {
b.plugin(plugin[0], plugin[1]);
}
b.plugin(plugin);
});
}

Expand Down
15 changes: 7 additions & 8 deletions test/browserify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('grunt-browserify-runner', function () {
it('passes the options hash along with the transform fn', function (done) {
var transforms = [[function () {}, {}]];
runner.run([], dest, {transform: transforms}, function () {
assert.ok(b().transform.calledWith(transforms[0][1], transforms[0][0]));
assert.ok(b().transform.calledWith(transforms[0]));
done();
});
});
Expand Down Expand Up @@ -320,20 +320,19 @@ describe('grunt-browserify-runner', function () {
it('registers the plugin', function (done) {
var b = stubBrowserify('plugin');
var runner = createRunner(b);
var plugin = function () {};
runner.run([], dest, {plugin: [plugin]}, function () {
assert.ok(b().plugin.calledWith(plugin));
var plugin = [function () {}];
runner.run([], dest, {plugin: plugin}, function () {
assert.ok(b().plugin.calledWith(plugin[0]));
done();
});
});
context('and when passing plugin options', function () {
it('registers the plugin options', function (done) {
var b = stubBrowserify('plugin');
var runner = createRunner(b);
var plugin = function () {};
var opts = {};
runner.run([], dest, {plugin: [[plugin, opts]]}, function () {
assert.ok(b().plugin.calledWith(plugin, opts));
var plugin = [[function () {}, {}]];
runner.run([], dest, {plugin: plugin}, function () {
assert.ok(b().plugin.calledWith(plugin[0]));
done();
});
});
Expand Down

0 comments on commit 2d41265

Please sign in to comment.