ZEST / base.gruntrunner / Index

Dependencies Dev Dependencies Peer Dependencies

Quality Build Status License

zest / base.gruntrunner

base.gruntrunner is a convenience module for adding grunt tasks to zest components.

general tasks

The grunt runner defines the following general tasks into the grunt file.

  • clean

    The clean task cleans up the output directory and restores the project to its original state

  • test

    The test task runs mocha tests and generates coverage report on the console

  • document

    The document task generates jsdoc documentation for the module sources

  • observe

    The observe task is used mainly for development. It is also the default grunt task. This task will watch for file changes and run jshint validations and test cases everytime any relevant file changes. observe has two variants:

    • grunt observe or grunt will observe file changes for code quality and tests
    • grunt observe --docs or grunt --docs will observe file changes for jsdoc documentation
  • coveralls The coveralls task is used to submit coverage report to coveralls. This task will only run successfully from travis-ci.

  • gh-pages The gh-pages task pushes the module documentation into the projects github site.

assumptions

The gruntrunner assumes the following

  • the test scripts are written using mocha.
  • the code is documented in JSDoc syntax.
  • the source files are present in the folder specified in directories.lib property in package.json
  • if directories.lib property in package.json is not found, the source directory is assumed to be ./lib
  • the test files are present in the folder specified in directories.test property in package.json
  • if directories.test property in package.json is not found, no test cases will run and no coverage will be generated
  • coverage reports are generated using blanket. So, if the test directory is present, coverage config must be present in package.json. Below is an example configuration.

    "config": {
        "blanket": {
            "pattern": "//^(?!.*/node_modules/).*/lib/" 
        } 
    }

usage

For the most simple usage where the default behavior is enough, one line in GruntFile.js will be enough.

    module.exports = require('./lib');

However, if you want to add other tasks and (maybe) fiddle with the gruntrunner tasks, you can use it as shown below.

    module.exports = function(grunt) {
        ...
        require('./lib')(grunt);
        ...
    }