Call after (or done) callback after task ends
Author: schoviCreated Apr 22, 2013Updated Aug 12, 2026
LabelsType: EnhancementComponent: tasks
I have developement task like
grunt.registerTask("dev", ["server", "jshint", "copy:dev", "coffeelint", "coffee", "watch"])
which will start server and copy files from /src into /public where is index.html and server pointed.
This will copy (or compile) lot of files into public directory.
After my work session I want to cleanup this directory. I looked for something like after, done or teardone callback which will run some task after the main task is killed, or finished.
var task = grunt.registerTask("dev", ["server", "jshint", "copy:dev", "coffeelint", "coffee", "watch"])
// With Deferred API this will be called when main task is break, killed, finished or end from any other reason
task.always(function() {
grunt.task.requires('cleanup');
})I tried to check sources, but did not find anything like this. Is there any way, how to do that, or is it planning feature?
Source: gruntjs/grunt