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

Removes array test for transform and plugin #319

Merged
merged 2 commits into from
Mar 11, 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
14 changes: 2 additions & 12 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
15 changes: 7 additions & 8 deletions test/browserify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down Expand Up @@ -307,20 +307,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