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

grunt-cli-issue-107: Add registered task listing ability #1619

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 21 additions & 9 deletions lib/grunt.js
Expand Up @@ -111,10 +111,16 @@ grunt.tasks = function(tasks, options, done) {
task.init(tasks, options);

verbose.writeln();
if (!tasksSpecified) {
verbose.writeln('No tasks specified, running default tasks.');

if (!grunt.cli.options.tasklist) {
if (!tasksSpecified) {
verbose.writeln('No tasks specified, running default tasks.');
}
verbose.writeflags(tasks, 'Running tasks');
}
else {
verbose.writeln('Listing registered tasks...\n');
}
verbose.writeflags(tasks, 'Running tasks');

// Handle otherwise unhandleable (probably asynchronous) exceptions.
var uncaughtHandler = function(e) {
Expand Down Expand Up @@ -147,10 +153,16 @@ grunt.tasks = function(tasks, options, done) {
}
});

// Execute all tasks, in order. Passing each task individually in a forEach
// allows the error callback to execute multiple times.
tasks.forEach(function(name) { task.run(name); });
// Run tasks async internally to reduce call-stack, per:
// https://github.com/gruntjs/grunt/pull/1026
task.start({asyncDone: true});
if (!grunt.cli.options.tasklist) {
// Execute all tasks, in order. Passing each task individually in a forEach
// allows the error callback to execute multiple times.
tasks.forEach(function(name) { task.run(name); });
// Run tasks async internally to reduce call-stack, per:
// https://github.com/gruntjs/grunt/pull/1026
task.start({asyncDone: true});
}
else {
// Do not run the registered tasks but just output them as JSON.
console.log(grunt.task._tasks);
}
};