Despite the large array of plugins available to Grunt users, situations might still arise where we would want to create tasks of our own. These situations are well provided for by Grunt, as it provides a set of utilities that make creating new ones quite simple.
In this example, we'll work with the basic project structure we created in the Installing Grunt on a project recipe in Chapter 1, Getting Started with Grunt. Be sure to refer to it if you are not yet familiar with its contents.
The following steps will take us through creating a simple task that prints the current system date and time.
First, we'll register our task with the name
datetime
and provide it with a description and an empty function as a placeholder. The following code shows the entire Grunt file with the task registration code highlighted:module.exports = function (grunt) { grunt.initConfig({}); grunt.registerTask('default', []); grunt.registerTask( 'datetime',...