domingo, 17 de agosto de 2014

My first Grunt file

I've investigating about automating (increase my productivity) writing tests and code in javascript, so I've found grunt

This little examples watch all .js files and validate with jshint

module.exports = function(grunt){
 grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  jshint:{
   all:['Gruntfile.js', './src/*.js', './spec/*.js']
  },
  watch:{
   files:'**/*.js',
   tasks:['jshint']
  }
 });

 grunt.loadNpmTasks('grunt-contrib-jshint');
 grunt.loadNpmTasks('grunt-contrib-watch');

 grunt.registerTask('test', ['jshint']);
};

my package.json
{
  "name": "grunt-test",
  "version": "0.0.1",
  "description": "simple grunt test",
  "keywords": [
    "grunt",
    "javascript",
    "jshint"
  ],
  "author": "Seymour Poler",
  "license": "GPL v2 or later",
  "devDependencies": {
    "grunt": "~0.4.5",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-watch": "~0.6.1"
  }
}

No hay comentarios:

Publicar un comentario