From 5c9d2df39cbcbafa18e61ffe0c8e4c8d5925e5c4 Mon Sep 17 00:00:00 2001 From: tleunen Date: Sun, 5 Apr 2015 09:32:29 -0400 Subject: [PATCH 1/2] browserify supports to receive an array for transform and plugin --- lib/runner.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 300aa49..56fbff3 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -87,23 +87,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); }); } From f310895a74f7219ff51744e89d086aa2747d42b8 Mon Sep 17 00:00:00 2001 From: tleunen Date: Sat, 2 May 2015 18:49:50 -0400 Subject: [PATCH 2/2] fixed tests --- test/browserify.test.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/browserify.test.js b/test/browserify.test.js index 40832e1..3d6c81e 100644 --- a/test/browserify.test.js +++ b/test/browserify.test.js @@ -257,7 +257,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(); }); }); @@ -307,9 +307,9 @@ 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(); }); }); @@ -317,10 +317,9 @@ describe('grunt-browserify-runner', 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(); }); });