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

Updates lodash, require only functions needed #63

Merged
merged 1 commit into from
Jul 24, 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
15 changes: 8 additions & 7 deletions lib/mergeFunction.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
var _ = require("lodash");
var isArray = require("lodash/isArray");
var merge = require("lodash/merge");

module.exports = function(grunt) {

function mergeFunction(a, b) {
if(_.isArray(a) && _.isArray(b)) {
if(isArray(a) && isArray(b)) {
return a.concat(b);
}
if(_.isArray(a) && !_.isArray(b)) {
if(isArray(a) && !isArray(b)) {
return a.map(function(item) {
return _.merge({}, {x:item}, {x:b}, mergeFunction).x;
return merge({}, {x:item}, {x:b}, mergeFunction).x;
});
}
if(_.isArray(b) && !_.isArray(a)) {
if(isArray(b) && !isArray(a)) {
return b.map(function(item) {
return _.merge({}, {x:a}, {x:item}, mergeFunction).x;
return merge({}, {x:a}, {x:item}, mergeFunction).x;
});
}
}

return mergeFunction;

};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "https://github.com/webpack/grunt-webpack/issues"
},
"dependencies": {
"lodash": "~1.2.0"
"lodash": "^4.0.0"
},
"peerDependencies": {
"webpack": "1.x",
Expand Down
4 changes: 2 additions & 2 deletions tasks/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

var path = require("path");
var _ = require("lodash");
var merge = require("lodash/merge");
module.exports = function(grunt) {
var getWithPlugins = require("../lib/getWithPlugins")(grunt);
var mergeFunction = require("../lib/mergeFunction")(grunt);
Expand All @@ -18,7 +18,7 @@ module.exports = function(grunt) {

grunt.registerMultiTask('webpack-dev-server', 'Start a webpack-dev-server.', function() {
var done = this.async();
var options = _.merge(
var options = merge(
{
port: 8080,
host: undefined,
Expand Down
19 changes: 11 additions & 8 deletions tasks/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
*/

var path = require("path");
var _ = require("lodash");
var merge = require("lodash/merge");
var map = require("lodash/map");
var isString = require("lodash/isString");
var isArray = require("lodash/isArray");

module.exports = function(grunt) {
var getWithPlugins = require("../lib/getWithPlugins")(grunt);
Expand All @@ -22,7 +25,7 @@ module.exports = function(grunt) {

grunt.registerMultiTask('webpack', 'Webpack files.', function() {
var done = this.async();
var options = _.merge(
var options = merge(
{x:{
context: ".",
output: {
Expand Down Expand Up @@ -59,13 +62,13 @@ module.exports = function(grunt) {
}

function convertPath(pth) {
if(_.isString(pth)){
if(isString(pth)){
return path.resolve(process.cwd(), pth);
}
else if(_.isArray(pth)){
return _.map(pth, function(p){
else if(isArray(pth)){
return map(pth, function(p){
// Arrays of paths can contain a mix of both strings and RegExps
if(_.isString(p)){
if(isString(p)){
return path.resolve(process.cwd(), p);
}
return p
Expand Down Expand Up @@ -137,7 +140,7 @@ module.exports = function(grunt) {
}

if(statsOptions) {
grunt.log.notverbose.writeln(stats.toString(grunt.util._.merge({
grunt.log.notverbose.writeln(stats.toString(grunt.util.merge({
colors: true,
hash: false,
timings: false,
Expand All @@ -147,7 +150,7 @@ module.exports = function(grunt) {
modules: false,
children: true
}, statsOptions)));
grunt.verbose.writeln(stats.toString(grunt.util._.merge({
grunt.verbose.writeln(stats.toString(grunt.util.merge({
colors: true
}, statsOptions)));
}
Expand Down