2019-06-14 admin


什么是grunt-simple-istanbul,A grunt wrapper for istanbul


Build Status downloads npm Code Climate Test Coverage dependencies

NPM info


A grunt wrapper for istanbul

Getting Started

If you haven’t used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you’re familiar with that process, you may install this plugin with this command:

npm install grunt-simple-istanbul --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with:


Alternatively, install and use task-master, and it will handle this (and a lot more!) for you.

The “istanbul” task

This module uses the simple-cli library to create a simple wrapper around istanbul.


The istanbul task is a multiTask, where the target is the istanbul command to run. You can configure as many istanbul commands as are useful to you either in your grunt.initConfig call or, as mentioned above, by using task-master. Options to the istanbul binary go under options. However, the special key simple indicates how this task should be run. See the examples below or the documentation for simple-cli.

  istanbul: {
    // istanbul instrument app --output instrumented -x **/node_modules/** -x **/coverage/** -x **/instrumented/** --no-compact true
    instrument: {
      options: {
        output: 'instrumented',
        x: ['**/node_modules/**', '**/coverage/**', '**/instrumented/**'],
        noCompact: true,
        simple: {
          args: ['app']
    // istanbul report --root /Users/foo/bar/my-repo/coverage --dir /Users/foo/bar/my-repo/coverage
    report: {
      options: {
        root: __dirname + '/coverage',
        dir: __dirname + '/coverage'
    // istanbul cover grunt coverage:unit --hook-run-in-context --root server --dir /Users/foo/bar/my-repo/coverage/unit -x **/node_modules/** -x **/public/** -x **/instrumented/**
    coverUnit: {
      options: {
        hookRunInContext: true,
        root: 'server'
        dir: __dirname + '/coverage/unit',
        x: ['**/node_modules/**', '**/public/**', '**/instrumented/**'],
        simple: {
          cmd: 'cover'
          args: ['grunt', 'coverage:unit']


转载请注明:文章转载自 JavaScript中文网 []