var grunt = require('grunt');

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-mocha-istanbul');
  
  grunt.initConfig({
    shell: {
      serverDemo: {
        command: 'node examples/server.js'
      },

      clientDemo: {
        command: 'node examples/client.js'
      },

      testUnit: {
        command: 'node_modules/.bin/mocha test/unit/*.spec.js test/unit/**/*.spec.js'
      },

      browserify: {
        command: 'browserify index.js -s SAME -o bundle/SAME.js'
      }
    },

    mocha_istanbul: {
      coverage: {
        src: 'test/unit',
        options: {
          coverageFolder: 'test/reports/',
          mask: '*.spec.js'
        }
      }
    }
  });

  grunt.registerTask('browserify', 'Bundle the library for browsers',
                     ['shell:browserify']);
  
  grunt.registerTask('demo:client', 'Run the client-side demo server',
                     ['browserify', 'shell:clientDemo']);
  grunt.registerTask('demo:server', 'Run the server-side demo',
                     ['shell:serverDemo']);

  grunt.registerTask('test', 'Run unit tests',
                     ['shell:testUnit']);
  grunt.registerTask('cover', 'Run unit tests + coverage report',
                     ['mocha_istanbul:coverage']);
};

@@ -142,19 +142,17 @@
 nbul');%0A
-  
 %0A
+
   grunt.
@@ -433,24 +433,143 @@
 '%0A      %7D,%0A%0A
+      jshint: %7B%0A        command: 'find lib test -not -path %5C'test/reports/*%5C' -name %5C'*.js%5C' %7C xargs jshint'%0A      %7D,%0A%0A
       browse
@@ -962,11 +962,9 @@
 %5D);%0A
-  
 %0A
+
   gr
@@ -1193,24 +1193,115 @@
 erDemo'%5D);%0A%0A
+  grunt.registerTask('jshint', 'Run jshint check',%0A                     %5B'shell:jshint'%5D);%0A
   grunt.regi
@@ -1439,24 +1439,24 @@
 ge report',%0A
-
             
@@ -1494,11 +1494,173 @@
 age'%5D);%0A
+  grunt.registerTask('validate', 'Run all checks and generate coverage',%0A                     %5B'shell:jshint',%0A                      'mocha_istanbul:coverage'%5D);%0A
 %7D;%0A

add jshint to gruntfile (closes #8)