Skip to content

Commit

Permalink
chore(project): update lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Dec 2, 2015
1 parent 0cc922f commit f4a69fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
28 changes: 17 additions & 11 deletions lib/bro.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ var browserify = require('browserify'),
var path = require('path'),
fs = require('fs');

var _ = require('lodash');
var reduce = require('lodash/collection/reduce'),
find = require('lodash/collection/find'),
any = require('lodash/collection/any'),
forEach = require('lodash/collection/forEach'),
assign = require('lodash/object/assign'),
omit = require('lodash/object/omit'),
debounce = require('lodash/function/debounce');


var BundleFile = require('./bundle-file');
Expand Down Expand Up @@ -68,16 +74,16 @@ function Bro(bundleFile) {
preprocessors = config.preprocessors;

// list of patterns using our preprocessor
var patterns = _.reduce(preprocessors, function(matched, val, key) {
var patterns = reduce(preprocessors, function(matched, val, key) {
if (val.indexOf('browserify') !== -1) {
matched.push(key);
}
return matched;
}, []);

// first file being preprocessed
var file = _.find(files, function(f) {
return _.any(patterns, function(p) {
var file = find(files, function(f) {
return any(patterns, function(p) {
return minimatch(f.pattern, p);
});
});
Expand Down Expand Up @@ -164,18 +170,18 @@ function Bro(bundleFile) {
log.warn('Invalid config option: "' + key + 's" should be "' + key + '"');
}

_.forEach([ 'transform', 'plugin' ], function(key) {
forEach([ 'transform', 'plugin' ], function(key) {
if (bopts[key + 's']) {
warn(key);
}
});

var browserifyOptions = _.extend({
var browserifyOptions = assign({
basedir: path.resolve(config.basePath),
// watchify.args
cache: {},
packageCache: {}
}, _.omit(bopts, [
}, omit(bopts, [
'transform', 'plugin', 'configure', 'bundleDelay'
]));

Expand All @@ -190,7 +196,7 @@ function Bro(bundleFile) {
var w = browserify(browserifyOptions);
w.setMaxListeners(Infinity);

_.forEach(bopts.plugin, function(p) {
forEach(bopts.plugin, function(p) {
// ensure we can pass plugin options as
// the first parameter
if (!Array.isArray(p)) {
Expand All @@ -199,7 +205,7 @@ function Bro(bundleFile) {
w.plugin.apply(w, p);
});

_.forEach(bopts.transform, function(t) {
forEach(bopts.transform, function(t) {
// ensure we can pass transform options as
// the first parameter
if (!Array.isArray(t)) {
Expand All @@ -216,7 +222,7 @@ function Bro(bundleFile) {
// register rebuild bundle on change
if (config.autoWatch) {
w = watchify(w, config.watchify);

log.info('registering rebuild (autoWatch=true)');

w.on('update', function(updated) {
Expand Down Expand Up @@ -254,7 +260,7 @@ function Bro(bundleFile) {
rebuild();
}

var rebuild = _.debounce(function rebuild() {
var rebuild = debounce(function rebuild() {

if (w._bundled) {
log.debug('resetting bundle');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"convert-source-map": "~0.3.3",
"hat": "0.0.3",
"js-string-escape": "^1.0.0",
"lodash": "~2.4.1",
"lodash": "^3.10.1",
"minimatch": "^1.0.0",
"os-shim": "~0.1.2",
"watchify": "3.2.1"
Expand Down
13 changes: 7 additions & 6 deletions test/runner.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';

var karma = require('karma'),
events = require('events'),
util = require('util'),
path = require('path'),
_ = require('lodash');
events = require('events'),
util = require('util'),
path = require('path');

var assign = require('lodash/object/assign');

function Runner() {
this.reset();
Expand Down Expand Up @@ -63,9 +64,9 @@ Runner.prototype.configure = function(configFile, config) {
configFile = path.resolve(configFile);
var karmaConfig = {};
require(configFile)({
set: function(conf) { _.assign(karmaConfig, conf); }
set: function(conf) { assign(karmaConfig, conf); }
});
config = _.assign({}, karmaConfig, config);
config = assign({}, karmaConfig, config);
return {
configFile: configFile,
frameworks: (config.frameworks || ['browserify']).concat('runner'),
Expand Down
4 changes: 2 additions & 2 deletions test/spec/logger-factory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _ = require('lodash');
var isString = require('lodash/lang/isString');

function Logger() {

Expand All @@ -12,7 +12,7 @@ function Logger() {
args = Array.prototype.slice.call(args);
logged.push(prefix + args.join(' '));

if (_.isString(args[0])) {
if (isString(args[0])) {
args[0] = prefix + args[0];
} else {
args.unshift(prefix);
Expand Down
10 changes: 6 additions & 4 deletions test/spec/pluginSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var _ = require('lodash');
var events = require('events');
var Bro = require('../../lib/bro');
var BundleFile = require('../../lib/bundle-file');
Expand All @@ -12,6 +11,9 @@ var fs = require('fs');
var unpack = require('browser-unpack');
var escape = require('js-string-escape');

var assign = require('lodash/object/assign'),
forEach = require('lodash/collection/forEach');

var BUNDLE_UPDATE_CHECK_DELAY = 3000;

function delay(fn, time) {
Expand Down Expand Up @@ -40,7 +42,7 @@ function createFile(p) {
function createConfig(config) {
config = config || {};

return _.extend({}, {
return assign({}, {
basePath: '',
files: [ createFilePattern('*.js') ],
preprocessors: {
Expand All @@ -60,7 +62,7 @@ function expectedBundle(filename) {
function expectBundleContainments(bundleFile, testFiles) {
var extractedFiles = unpack(bundleFile.bundled).map(function(row) { return row.id; });

_.forEach(testFiles, function(f) {
forEach(testFiles, function(f) {
expect(extractedFiles).to.contain(f.path);
});
}
Expand Down Expand Up @@ -108,7 +110,7 @@ TestPlugin.prototype.preprocess = function preprocess(bundle, testFiles, done) {
// Karma does not necessarily preprocess test files in the order they are given.
var shuffledTestFiles = testFiles.slice(0).reverse();

_.forEach(shuffledTestFiles, function(file) {
forEach(shuffledTestFiles, function(file) {
process(plugin.testFilePreprocessor, file);
});
};
Expand Down

0 comments on commit f4a69fb

Please sign in to comment.