1 | # gulp-espower [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]
|
2 |
|
3 | > A [gulp](https://github.com/wearefractal/gulp) plugin for [power-assert](http://github.com/twada/power-assert).
|
4 |
|
5 | ## Description
|
6 | `gulp-espower` is a gulp plugin to instrument "Power Assert" feature into your code.
|
7 |
|
8 |
|
9 | Internally, `gulp-espower` task uses `espower` module that manipulates assertion expression (JavaScript Code) represented as [Mozilla JavaScript AST](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API), to instrument power-assert feature into the code. The magic is done by using [Esprima](http://esprima.org/) and [Escodegen](https://github.com/Constellation/escodegen).
|
10 |
|
11 |
|
12 | Please note that `gulp-espower` is a beta version product. Pull-requests, issue reports and patches are always welcomed. See [power-assert](http://github.com/twada/power-assert) project for more documentation.
|
13 |
|
14 |
|
15 | ## Usage
|
16 |
|
17 | First, install `gulp-espower` as a development dependency:
|
18 |
|
19 | ```shell
|
20 | npm install --save-dev gulp-espower
|
21 | ```
|
22 |
|
23 | Then, add it to your `gulpfile.js`:
|
24 |
|
25 | ```javascript
|
26 | var espower = require('gulp-espower');
|
27 |
|
28 | gulp.src('./test/*.js')
|
29 | .pipe(espower())
|
30 | .pipe(gulp.dest('./dist'));
|
31 | ```
|
32 |
|
33 |
|
34 | ## Source maps
|
35 |
|
36 | gulp-espower can be used with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the instrumented javascript code. Note that you should `init` gulp-sourcemaps prior to running the gulp-espower and `write` the source maps after. gulp-espower works well with some gulp plugins that supports [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
|
37 |
|
38 | ```javascript
|
39 | var espower = require('gulp-espower');
|
40 | var coffee = require('gulp-coffee');
|
41 | var concat = require('gulp-concat');
|
42 | var sourcemaps = require('gulp-sourcemaps');
|
43 |
|
44 | // compile, instrument then concatinate
|
45 | gulp.src('./test/*test.coffee')
|
46 | .pipe(sourcemaps.init())
|
47 | .pipe(coffee())
|
48 | .pipe(espower())
|
49 | .pipe(concat('all_test.js'))
|
50 | .pipe(sourcemaps.write())
|
51 | .pipe(gulp.dest('./build'));
|
52 | // will write the source maps inline in the code
|
53 | ```
|
54 |
|
55 | For more information, see [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
|
56 |
|
57 |
|
58 | ## API
|
59 |
|
60 | ### espower(options)
|
61 |
|
62 | #### options.patterns
|
63 |
|
64 | | type | default value |
|
65 | |:--------------------|:--------------------|
|
66 | | `Array` of `string` | objects shown below |
|
67 |
|
68 | ```javascript
|
69 | [
|
70 | 'assert(value, [message])',
|
71 | 'assert.ok(value, [message])',
|
72 | 'assert.equal(actual, expected, [message])',
|
73 | 'assert.notEqual(actual, expected, [message])',
|
74 | 'assert.strictEqual(actual, expected, [message])',
|
75 | 'assert.notStrictEqual(actual, expected, [message])',
|
76 | 'assert.deepEqual(actual, expected, [message])',
|
77 | 'assert.notDeepEqual(actual, expected, [message])'
|
78 | ]
|
79 | ```
|
80 |
|
81 | Target patterns for power assert feature instrumentation.
|
82 |
|
83 | If callee name (for example, `assert.equal`) matches exactly and number of arguments is satisfied, then the assertion will be modified.
|
84 | Detection is done by [escallmatch](http://github.com/twada/escallmatch). Any arguments enclosed in bracket (for example, `[message]`) means optional parameters. Without bracket means mandatory parameters.
|
85 |
|
86 |
|
87 | ## CHANGELOG
|
88 |
|
89 | See [CHANGELOG](https://github.com/twada/gulp-espower/blob/master/CHANGELOG.md)
|
90 |
|
91 |
|
92 | ## AUTHOR
|
93 |
|
94 | * [Takuto Wada](http://github.com/twada)
|
95 |
|
96 |
|
97 | ## CONTRIBUTORS
|
98 |
|
99 | * [bouzuya](http://bouzuya.net)
|
100 |
|
101 |
|
102 | ## License
|
103 |
|
104 | Licensed under the [MIT](https://github.com/twada/gulp-espower/blob/master/LICENSE-MIT) license.
|
105 |
|
106 | [npm-url]: https://npmjs.org/package/gulp-espower
|
107 | [npm-image]: https://badge.fury.io/js/gulp-espower.svg
|
108 |
|
109 | [travis-url]: http://travis-ci.org/twada/gulp-espower
|
110 | [travis-image]: https://secure.travis-ci.org/twada/gulp-espower.svg?branch=master
|
111 |
|
112 | [depstat-url]: https://gemnasium.com/twada/gulp-espower
|
113 | [depstat-image]: https://gemnasium.com/twada/gulp-espower.svg
|