Vitaliy Petrychuk
Front-End Developer @SoftServe
Grunt is a task-based command-line build tool for JavaScript projects.
Automation
Node.js is a software platform that is used to build scalable network server-side applications.
Grunt's Command Line Interface (CLI)
should be installed globally:
$ npm install -g grunt-cli
$ npm install grunt --save-dev
This will install the latest version of Grunt in your current directory and will add grunt as a dependency to devDependencies in your package.json file.
{
"name" : "project-name",
"version" : 0.0.1,
"devDependencies" : {
"grunt" : "~0.4.1",
"grunt-contrib-jshint" : "~0.6.4"
}
}
After executing command below npm will install all defined dependencies:
$ npm install
module.exports = function (grunt) {
// Configure tasks
grunt.initConfig({
jshint : {
options : {
curly : true,
eqnull : true
},
all : ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
}
});
// Load plugins
grunt.loadNpmTask('grunt-contrib-jshint');
// Register custom tasks
grunt.registerTask('default', ['jshint']);
};
default
task refers to the jshint
task.
default
is a default Grunt task.
So these commands:
$ grunt
$ grunt default
$ grunt jshint
Do the same thing:
$ grunt
Running "jshint:dist" (jshint) task
>> 42 files lint free.
Done, without errors.