Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating task.loadNpmTasks with preliminary "collection" plugin suppo…

…rt. Closes gh-379.
  • Loading branch information...
commit 4d5d50b0205a40d5b0e7b4cd4b3ba16a2f192410 1 parent dfee7e4
@cowboy authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 lib/grunt/task.js
View
22 lib/grunt/task.js
@@ -299,7 +299,27 @@ task.loadTasks = function(tasksdir) {
// relative to the base dir).
task.loadNpmTasks = function(name) {
loadTasksMessage('"' + name + '" local Npm module');
- var tasksdir = path.resolve('node_modules', name, 'tasks');
+ var root = path.resolve('node_modules');
+ var pkgfile = path.join(root, name, 'package.json');
+ var pkg = existsSync(pkgfile) ? grunt.file.readJSON(pkgfile) : {keywords: []};
+
+ // Process collection plugins.
+ if (pkg.keywords.indexOf('gruntcollection') !== -1) {
+ Object.keys(pkg.dependencies).forEach(function(depName) {
+ // Npm sometimes pulls dependencies out if they're shared, so find
+ // upwards if not found locally.
+ var filepath = grunt.file.findup(path.resolve('node_modules', name),
+ 'node_modules/' + depName);
+ if (filepath) {
+ // Load this task plugin recursively.
+ task.loadNpmTasks(path.relative(root, filepath));
+ }
+ });
+ return;
+ }
+
+ // Process task plugins.
+ var tasksdir = path.join(root, name, 'tasks');
if (existsSync(tasksdir)) {
task.searchDirs.unshift(tasksdir);
loadTasks(tasksdir);
Please sign in to comment.
Something went wrong with that request. Please try again.