Skip to content

Commit

Permalink
load global task collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsiaoming Yang committed Mar 6, 2013
1 parent aa29aa1 commit 4f24d59
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/sdk/grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,30 @@ grunt.spm.loadTasks = function(tasks) {
tasks = [tasks];
}
tasks.forEach(function(task) {
grunt.loadTasks(path.join(NODE_PATH, task, 'tasks'));
var rootdir = path.join(NODE_PATH, task);
var pkgfile = path.join(rootdir, 'package.json');
var pkg = grunt.file.exists(pkgfile) ? grunt.file.readJSON(pkgfile): {keywords: []};
// Process collection plugins
if (pkg.keywords && pkg.keywords.indexOf('gruntcollection') !== -1) {
Object.keys(pkg.dependencies).forEach(function(depName) {
var filepath = grunt.file.findup(path.join(rootdir, 'node_modules', depName), {
cwd: rootdir,
nocase: true
});
if (filepath) {
// Load this task plugin recursively
grunt.spm.loadTasks(path.relative(NODE_PATH, filepath));
}
});
return;
}
// Process task plugins.
var taskdir = path.join(NODE_PATH, task, 'tasks');
if (grunt.file.exists(taskdir)) {
grunt.loadTasks(taskdir);
} else {
grunt.log.error('Global task ' + task + ' not found.');
}
});
} else {
grunt.log.error('Environment variable required: "NODE_PATH"');
Expand Down

0 comments on commit 4f24d59

Please sign in to comment.