├── .gitignore ├── .jshintrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE-MIT ├── README.md ├── index.js ├── package.json └── test ├── expected ├── customized.js ├── example-with-sourcemap.js └── example.js ├── fixtures ├── customized.js ├── example.js └── syntax-error.js └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log 4 | temp/ 5 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "camelcase": true, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "eqnull": true, 7 | "esnext": true, 8 | "evil": true, 9 | "forin": false, 10 | "immed": true, 11 | "indent": 4, 12 | "latedef": true, 13 | "maxdepth": 4, 14 | "maxparams": 4, 15 | "newcap": true, 16 | "noarg": true, 17 | "node": true, 18 | "nonew": true, 19 | "onevar": true, 20 | "quotmark": "single", 21 | "smarttabs": true, 22 | "strict": true, 23 | "trailing": true, 24 | "undef": true, 25 | "unused": "vars", 26 | "white": true 27 | } 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | node_js: 4 | - "4" 5 | - "5" 6 | - "6" 7 | - "7" 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.1.0](https://github.com/power-assert-js/gulp-espower/releases/tag/v1.1.0) (2016-11-22) 2 | 3 | 4 | #### Features 5 | 6 | * [Enable transparent assertion enhancement, embed value capturing helper into transpiled code (by upgrading espower-source to 2.0.0)](https://github.com/power-assert-js/gulp-espower/pull/6) 7 | 8 | 9 | ### [1.0.2](https://github.com/power-assert-js/gulp-espower/releases/tag/v1.0.2) (2015-12-10) 10 | 11 | 12 | #### Bug Fixes 13 | 14 | * fix typo in PluginError call ([070431fe](https://github.com/power-assert-js/gulp-espower/commit/070431fe6dad227dd5396da2a2d9f3b0715d8eef)) 15 | 16 | 17 | ### [1.0.1](https://github.com/power-assert-js/gulp-espower/releases/tag/v1.0.1) (2015-10-08) 18 | 19 | 20 | * update espower to 1.0.7 ([5173f4b](https://github.com/power-assert-js/gulp-espower/commit/5173f4bcb034670a75442143074ad4468e5c23c1)) 21 | * update vinyl-sourcemaps-apply to 0.2.0 ([7ae9fcb](https://github.com/power-assert-js/gulp-espower/commit/7ae9fcb955e0476bd2dcd314a155e80d7ff4ce77)) 22 | * update bufferstreams to 1.1.0 ([1c19377](https://github.com/power-assert-js/gulp-espower/commit/1c19377a7786cdcaadee85882984a0bff3434731)) 23 | 24 | 25 | ## [1.0.0](https://github.com/power-assert-js/gulp-espower/releases/tag/v1.0.0) (2015-08-22) 26 | 27 | 28 | #### Bug Fixes 29 | 30 | * should emit error when the file has a syntax error, even if using Streams ([a786374d](https://github.com/power-assert-js/gulp-espower/commit/a786374d01e0dd61ae8894ecbd756d15033ab7ae)) 31 | 32 | 33 | #### Features 34 | 35 | * transfer to power-assert-js organization ([a6df50ab](https://github.com/power-assert-js/gulp-espower/commit/a6df50abe5f0756e644b490a407ff8a6db09b732)) 36 | * [use file.cwd for default sourceRoot](https://github.com/power-assert-js/gulp-espower/pull/4) 37 | 38 | 39 | ### [0.10.1](https://github.com/power-assert-js/gulp-espower/releases/tag/v0.10.1) (2015-03-04) 40 | 41 | 42 | #### Bug Fixes 43 | 44 | * fix a bug that throw an error when the file has a syntax error ([603a681b](https://github.com/power-assert-js/gulp-espower/commit/603a681b9be2b809970c9aa89052d954feb2134b)) (by @bouzuya) 45 | 46 | 47 | ## [0.10.0](https://github.com/power-assert-js/gulp-espower/releases/tag/v0.10.0) (2014-11-11) 48 | 49 | 50 | * update espower and espower-source to 0.10.0 ([724aead0](https://github.com/power-assert-js/gulp-espower/commit/724aead0ac2ec8be7572eb133956729813d56518)) 51 | * update vinyl-sourcemaps-apply ([c19ca9ab](https://github.com/power-assert-js/gulp-espower/commit/c19ca9abe9da0eec3c8134e63ccd72ec240092e5)) 52 | 53 | 54 | ### 0.9.1 (2014-09-17) 55 | 56 | 57 | #### Features 58 | 59 | * update espower and espower-source to 0.9.1 ([681f1ab9](https://github.com/power-assert-js/gulp-espower/commit/681f1ab9b786066fd66236686f0f118470851ef5)) 60 | 61 | 62 | ## 0.9.0 (2014-09-02) 63 | 64 | 65 | #### Features 66 | 67 | * gulp-sourcemaps support ([caf2a275](https://github.com/power-assert-js/gulp-espower/commit/caf2a275aa26a1ce2ff43b024d73a8dc055feb3d)) 68 | * keep paths relative until the end of chain ([9dc8f50b](https://github.com/power-assert-js/gulp-espower/commit/9dc8f50b0ecf3a0d77c472bf75e7730a54748c9f)) 69 | 70 | 71 | ## 0.8.0 (2014-08-12) 72 | 73 | 74 | #### Features 75 | 76 | * update espower-source to 0.8.0 ([a9ab1f7d](https://github.com/power-assert-js/gulp-espower/commit/a9ab1f7de7275b717589bd8eb8048b89bc575763)) 77 | * now supports streams as well ([ada19f90](https://github.com/power-assert-js/gulp-espower/commit/ada19f90f0dfc674405342310259e31ddd3a6dd0)) 78 | 79 | 80 | #### Breaking Changes 81 | 82 | * update espower-source to 0.8.0 ([a9ab1f7d](https://github.com/power-assert-js/gulp-espower/commit/a9ab1f7de7275b717589bd8eb8048b89bc575763)) 83 | 84 | If you already customize instrumentation pattern using `powerAssertVariableName` and `targetMethods`, you need to migarte. To migrate, change your code from the following: 85 | 86 | ```javascript 87 | var espower = require("gulp-espower"); 88 | 89 | gulp.src("./test/*.js") 90 | .pipe(espower({ 91 | powerAssertVariableName: 'yourAssert', 92 | targetMethods: { 93 | oneArg: [ 94 | 'okay' 95 | ], 96 | twoArgs: [ 97 | 'equal', 98 | 'customEqual' 99 | ] 100 | } 101 | })) 102 | .pipe(gulp.dest("./dist")); 103 | ``` 104 | 105 | To: 106 | 107 | ```javascript 108 | var espower = require("gulp-espower"); 109 | 110 | gulp.src("./test/*.js") 111 | .pipe(espower({ 112 | patterns: [ 113 | 'yourAssert(value, [message])', 114 | 'yourAssert.okay(value, [message])', 115 | 'yourAssert.equal(actual, expected, [message])', 116 | 'yourAssert.customEqual(actual, expected, [message])' 117 | ] 118 | })) 119 | .pipe(gulp.dest("./dist")); 120 | ``` 121 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2017 Takuto Wada, https://github.com/power-assert-js/gulp-espower 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gulp-espower 2 | 3 | [![Build Status][travis-image]][travis-url] 4 | [![NPM version][npm-image]][npm-url] 5 | [![Dependency Status][depstat-image]][depstat-url] 6 | [![License][license-image]][license-url] 7 | 8 | > A [gulp](https://github.com/gulpjs/gulp) plugin for [power-assert](https://github.com/power-assert-js/power-assert). 9 | 10 | ## Description 11 | 12 | `gulp-espower` is a gulp plugin to instrument "Power Assert" feature into your code. 13 | 14 | 15 | Internally, `gulp-espower` task uses `espower` module that manipulates assertion expression (JavaScript Code) defined in [The ESTree Spec](https://github.com/estree/estree) (formerly known as [Mozilla SpiderMonkey Parser API](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). 16 | 17 | 18 | Pull-requests, issue reports and patches are always welcomed. See [power-assert](https://github.com/power-assert-js/power-assert) project for more documentation. 19 | 20 | 21 | ## Usage 22 | 23 | First, install `gulp-espower` as a development dependency: 24 | 25 | ```shell 26 | npm install --save-dev gulp-espower 27 | ``` 28 | 29 | Then, add it to your `gulpfile.js`: 30 | 31 | ```javascript 32 | var espower = require('gulp-espower'); 33 | 34 | gulp.src('./test/*.js') 35 | .pipe(espower()) 36 | .pipe(gulp.dest('./dist')); 37 | ``` 38 | 39 | 40 | ## Source maps 41 | 42 | gulp-espower works 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). 43 | 44 | ```javascript 45 | var espower = require('gulp-espower'); 46 | var coffee = require('gulp-coffee'); 47 | var concat = require('gulp-concat'); 48 | var sourcemaps = require('gulp-sourcemaps'); 49 | 50 | // compile, instrument then concatinate 51 | gulp.src('./test/*test.coffee') 52 | .pipe(sourcemaps.init()) 53 | .pipe(coffee()) 54 | .pipe(espower()) 55 | .pipe(concat('all_test.js')) 56 | .pipe(sourcemaps.write()) 57 | .pipe(gulp.dest('./build')); 58 | // will write the source maps inline in the code 59 | ``` 60 | 61 | For more information, see [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps). 62 | 63 | 64 | ## API 65 | 66 | ### espower(options) 67 | 68 | #### options.patterns 69 | 70 | | type | default value | 71 | |:--------------------|:--------------------| 72 | | `Array` of `string` | objects shown below | 73 | 74 | ```javascript 75 | [ 76 | 'assert(value, [message])', 77 | 'assert.ok(value, [message])', 78 | 'assert.equal(actual, expected, [message])', 79 | 'assert.notEqual(actual, expected, [message])', 80 | 'assert.strictEqual(actual, expected, [message])', 81 | 'assert.notStrictEqual(actual, expected, [message])', 82 | 'assert.deepEqual(actual, expected, [message])', 83 | 'assert.notDeepEqual(actual, expected, [message])', 84 | 'assert.deepStrictEqual(actual, expected, [message])', 85 | 'assert.notDeepStrictEqual(actual, expected, [message])' 86 | ] 87 | ``` 88 | 89 | Target patterns for power assert feature instrumentation. 90 | 91 | If callee name (for example, `assert.equal`) matches exactly and number of arguments is satisfied, then the assertion will be modified. 92 | Detection is done by [escallmatch](https://github.com/twada/escallmatch). Any arguments enclosed in bracket (for example, `[message]`) means optional parameters. Without bracket means mandatory parameters. 93 | 94 | 95 | ## CHANGELOG 96 | 97 | See [CHANGELOG](https://github.com/power-assert-js/gulp-espower/blob/master/CHANGELOG.md) 98 | 99 | 100 | ## OUR SUPPORT POLICY 101 | 102 | We support Node under maintenance. In other words, we stop supporting old Node version when [their maintenance ends](https://github.com/nodejs/LTS). 103 | 104 | This means that any other environment is not supported. 105 | 106 | NOTE: If gulp-espower works in any of the unsupported environments, it is purely coincidental and has no bearing on future compatibility. Use at your own risk. 107 | 108 | 109 | ## AUTHOR 110 | 111 | * [Takuto Wada](https://github.com/twada) 112 | 113 | 114 | ## CONTRIBUTORS 115 | 116 | * [bouzuya](http://bouzuya.net) 117 | 118 | 119 | ## License 120 | 121 | Licensed under the [MIT](https://github.com/power-assert-js/gulp-espower/blob/master/LICENSE-MIT) license. 122 | 123 | [npm-url]: https://npmjs.org/package/gulp-espower 124 | [npm-image]: https://badge.fury.io/js/gulp-espower.svg 125 | 126 | [travis-url]: https://travis-ci.org/power-assert-js/gulp-espower 127 | [travis-image]: https://secure.travis-ci.org/power-assert-js/gulp-espower.svg?branch=master 128 | 129 | [depstat-url]: https://gemnasium.com/power-assert-js/gulp-espower 130 | [depstat-image]: https://gemnasium.com/power-assert-js/gulp-espower.svg 131 | 132 | [license-url]: https://github.com/power-assert-js/gulp-espower/blob/master/LICENSE-MIT 133 | [license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat 134 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * gulp-espower - A gulp plugin for power-assert. 3 | * 4 | * https://github.com/power-assert-js/gulp-espower 5 | * 6 | * Copyright (c) 2013-2017 Takuto Wada 7 | * Licensed under the MIT license. 8 | * https://github.com/power-assert-js/gulp-espower/blob/master/LICENSE-MIT 9 | */ 10 | 'use strict'; 11 | 12 | var through = require('through2'); 13 | var gutil = require('gulp-util'); 14 | var extend = require('xtend'); 15 | var BufferStreams = require('bufferstreams'); 16 | var mergeVisitors = require('merge-estraverse-visitors'); 17 | var empowerAssert = require('empower-assert'); 18 | var estraverse = require('estraverse'); 19 | var espower = require('espower'); 20 | var espowerSource = require('espower-source'); 21 | var esprima = require('esprima'); 22 | var escodegen = require('escodegen'); 23 | var applySourceMap = require('vinyl-sourcemaps-apply'); 24 | var transfer = require('multi-stage-sourcemap').transfer; 25 | var convert = require('convert-source-map'); 26 | 27 | function mergeSourceMap(incomingSourceMap, outgoingSourceMap) { 28 | if (typeof outgoingSourceMap === 'string' || outgoingSourceMap instanceof String) { 29 | outgoingSourceMap = JSON.parse(outgoingSourceMap); 30 | } 31 | if (!incomingSourceMap) { 32 | return outgoingSourceMap; 33 | } 34 | return JSON.parse(transfer({fromSourceMap: outgoingSourceMap, toSourceMap: incomingSourceMap})); 35 | } 36 | 37 | function mergeEspowerOptions (options, file) { 38 | return extend(espower.defaultOptions(), { 39 | sourceRoot: file.cwd, 40 | path: file.path 41 | }, options); 42 | } 43 | 44 | function transform (file, encoding, opt) { 45 | var inMap = file.sourceMap; 46 | var escodegenOptions = {}; 47 | var jsCode = file.contents.toString(encoding); 48 | 49 | var jsAst = esprima.parse(jsCode, {tolerant: true, loc: true}); 50 | 51 | var espowerOptions = mergeEspowerOptions(opt, file); 52 | if (inMap) { 53 | espowerOptions.sourceMap = inMap; 54 | // https://github.com/floridoo/gulp-sourcemaps#plugin-developers-only-how-to-add-source-map-support-to-plugins 55 | escodegenOptions = extend(escodegenOptions, { 56 | // use file.relative for `file` and `sources` to keep paths relative until the end of chain 57 | file: file.relative, 58 | sourceMap: file.relative, 59 | // do not set sourceMapRoot to keep paths relative until the end of chain 60 | // sourceMapRoot: file.base, 61 | sourceMapWithCode: true 62 | }); 63 | } 64 | var modifiedAst = estraverse.replace(jsAst, mergeVisitors([ 65 | { 66 | enter: empowerAssert.enter 67 | }, 68 | espower.createVisitor(jsAst, espowerOptions) 69 | ])); 70 | var escodegenOutput = escodegen.generate(modifiedAst, escodegenOptions); 71 | if (inMap) { 72 | file.contents = new Buffer(escodegenOutput.code); 73 | var outMap = convert.fromJSON(escodegenOutput.map.toString()); 74 | outMap.setProperty('sources', inMap.sources); 75 | outMap.setProperty('sourcesContent', inMap.sourcesContent); 76 | 77 | var reMap; 78 | if (inMap.mappings === '') { 79 | applySourceMap(file, outMap.toJSON()); 80 | reMap = convert.fromObject(file.sourceMap); 81 | } else { 82 | reMap = convert.fromObject(mergeSourceMap(inMap, outMap.toJSON())); 83 | } 84 | reMap.setProperty('sources', inMap.sources); 85 | reMap.setProperty('sourcesContent', inMap.sourcesContent); 86 | // do not set sourceMapRoot to keep paths relative until the end of chain 87 | // reMap.setProperty('sourceRoot', file.base); 88 | 89 | file.sourceMap = reMap.toObject(); 90 | } else { 91 | file.contents = new Buffer(escodegenOutput); 92 | } 93 | } 94 | 95 | module.exports = function (opt) { 96 | return through.obj(function (file, encoding, callback) { 97 | encoding = encoding || 'utf8'; 98 | if (file.isNull()) { 99 | this.push(file); 100 | } else if (file.isBuffer()) { 101 | try { 102 | transform(file, encoding, opt); 103 | this.push(file); 104 | } catch (err) { 105 | return callback(new gutil.PluginError('gulp-espower', err, {showStack: true})); 106 | } 107 | } else if (file.isStream()) { 108 | file.contents = file.contents.pipe(new BufferStreams(function(err, buf, cb) { 109 | if(err) { 110 | cb(new gutil.PluginError('gulp-espower', err, {showStack: true})); 111 | } else { 112 | var modifiedCode; 113 | try { 114 | modifiedCode = espowerSource(buf.toString(encoding), file.path, mergeEspowerOptions(opt, file)); 115 | } catch (err) { 116 | return callback(new gutil.PluginError('gulp-espower', err, {showStack: true})); 117 | } 118 | cb(null, new Buffer(modifiedCode)); 119 | } 120 | })); 121 | this.push(file); 122 | } 123 | callback(); 124 | }); 125 | }; 126 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-espower", 3 | "description": "A gulp plugin for power-assert", 4 | "version": "1.1.0", 5 | "author": { 6 | "name": "Takuto Wada", 7 | "email": "takuto.wada@gmail.com", 8 | "url": "https://github.com/twada" 9 | }, 10 | "bugs": "https://github.com/power-assert-js/gulp-espower/issues", 11 | "contributors": [ 12 | { 13 | "name": "bouzuya", 14 | "mail": "m@bouzuya.net", 15 | "url": "http://bouzuya.net" 16 | } 17 | ], 18 | "dependencies": { 19 | "bufferstreams": "^1.1.0", 20 | "convert-source-map": "^1.1.1", 21 | "empower-assert": "^1.0.0", 22 | "escodegen": "^1.6.1", 23 | "espower": "^2.0.0", 24 | "espower-source": "^2.0.0", 25 | "esprima": "^3.0.0", 26 | "estraverse": "^4.0.0", 27 | "gulp-util": "^3.0.5", 28 | "merge-estraverse-visitors": "^1.0.0", 29 | "multi-stage-sourcemap": "^0.2.1", 30 | "through2": "^2.0.0", 31 | "vinyl-sourcemaps-apply": "^0.2.0", 32 | "xtend": "^4.0.0" 33 | }, 34 | "devDependencies": { 35 | "event-stream": "^3.3.1", 36 | "jshint": "^2.8.0", 37 | "mocha": "^3.0.0" 38 | }, 39 | "engines": { 40 | "node": ">=0.8.0", 41 | "npm": ">=1.2.10" 42 | }, 43 | "files": [ 44 | "LICENSE-MIT", 45 | "CHANGELOG.md", 46 | "README.md", 47 | "index.js", 48 | "package.json" 49 | ], 50 | "homepage": "https://github.com/power-assert-js/gulp-espower", 51 | "keywords": [ 52 | "assert", 53 | "assertion", 54 | "gulpplugin", 55 | "power-assert", 56 | "test", 57 | "testing" 58 | ], 59 | "license": "MIT", 60 | "main": "./index.js", 61 | "repository": { 62 | "type": "git", 63 | "url": "git://github.com/power-assert-js/gulp-espower.git" 64 | }, 65 | "scripts": { 66 | "lint": "jshint index.js", 67 | "test": "npm run lint && mocha" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /test/expected/customized.js: -------------------------------------------------------------------------------- 1 | var _PowerAssertRecorder1 = function () { 2 | function PowerAssertRecorder() { 3 | this.captured = []; 4 | } 5 | PowerAssertRecorder.prototype._capt = function _capt(value, espath) { 6 | this.captured.push({ 7 | value: value, 8 | espath: espath 9 | }); 10 | return value; 11 | }; 12 | PowerAssertRecorder.prototype._expr = function _expr(value, source) { 13 | return { 14 | powerAssertContext: { 15 | value: value, 16 | events: this.captured 17 | }, 18 | source: source 19 | }; 20 | }; 21 | return PowerAssertRecorder; 22 | }(); 23 | var _rec1 = new _PowerAssertRecorder1(); 24 | var _rec2 = new _PowerAssertRecorder1(); 25 | var _rec3 = new _PowerAssertRecorder1(); 26 | var _rec4 = new _PowerAssertRecorder1(); 27 | var empower = require('empower'), formatter = require('power-assert-formatter'), busterAssertions = require('buster-assertions'), refute = empower(busterAssertions.refute, formatter(), { 28 | targetMethods: { 29 | oneArg: ['isNull'], 30 | twoArgs: ['same'] 31 | } 32 | }), truthy = 'true', falsy = 'false'; 33 | refute(_rec1._expr(_rec1._capt(truthy, 'arguments/0'), { 34 | content: 'refute(truthy)', 35 | filepath: 'test/fixtures/customized.js', 36 | line: 7 37 | })); 38 | refute.isNull(_rec2._expr(_rec2._capt(falsy, 'arguments/0'), { 39 | content: 'refute.isNull(falsy)', 40 | filepath: 'test/fixtures/customized.js', 41 | line: 8 42 | })); 43 | refute.same(_rec3._expr(_rec3._capt(truthy, 'arguments/0'), { 44 | content: 'refute.same(truthy, falsy)', 45 | filepath: 'test/fixtures/customized.js', 46 | line: 9 47 | }), _rec4._expr(_rec4._capt(falsy, 'arguments/1'), { 48 | content: 'refute.same(truthy, falsy)', 49 | filepath: 'test/fixtures/customized.js', 50 | line: 9 51 | })); 52 | -------------------------------------------------------------------------------- /test/expected/example-with-sourcemap.js: -------------------------------------------------------------------------------- 1 | var _PowerAssertRecorder1 = function () { 2 | function PowerAssertRecorder() { 3 | this.captured = []; 4 | } 5 | PowerAssertRecorder.prototype._capt = function _capt(value, espath) { 6 | this.captured.push({ 7 | value: value, 8 | espath: espath 9 | }); 10 | return value; 11 | }; 12 | PowerAssertRecorder.prototype._expr = function _expr(value, source) { 13 | return { 14 | powerAssertContext: { 15 | value: value, 16 | events: this.captured 17 | }, 18 | source: source 19 | }; 20 | }; 21 | return PowerAssertRecorder; 22 | }(); 23 | var _rec1 = new _PowerAssertRecorder1(); 24 | var _rec2 = new _PowerAssertRecorder1(); 25 | var _rec3 = new _PowerAssertRecorder1(); 26 | var assert = require('power-assert'), truthy = 'true', falsy = 'false'; 27 | assert(_rec1._expr(_rec1._capt(falsy, 'arguments/0'), { 28 | content: 'assert(falsy)', 29 | filepath: 'test/fixtures/example.js', 30 | line: 4 31 | })); 32 | assert.equal(_rec2._expr(_rec2._capt(truthy, 'arguments/0'), { 33 | content: 'assert.equal(truthy, falsy)', 34 | filepath: 'test/fixtures/example.js', 35 | line: 5 36 | }), _rec3._expr(_rec3._capt(falsy, 'arguments/1'), { 37 | content: 'assert.equal(truthy, falsy)', 38 | filepath: 'test/fixtures/example.js', 39 | line: 5 40 | })); 41 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvZml4dHVyZXMvZXhhbXBsZS5qcyJdLCJuYW1lcyI6WyJfUG93ZXJBc3NlcnRSZWNvcmRlcjEiLCJQb3dlckFzc2VydFJlY29yZGVyIiwiY2FwdHVyZWQiLCJwcm90b3R5cGUiLCJfY2FwdCIsInZhbHVlIiwiZXNwYXRoIiwicHVzaCIsIl9leHByIiwic291cmNlIiwicG93ZXJBc3NlcnRDb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UFKLEtBQUEsQ0FBQUksS0FBQSxDQUFBUixLQUFBLENBQUFjLEtBQUE7QUFBQSxJQUFBQyxPQUFBO0FBQUEsSUFBQUMsUUFBQTtBQUFBLElBQUFDLElBQUE7QUFBQSxFQUFQLEVBSEE7QUFJQU4sTUFBQSxDQUFPTyxLQUFQLENBQWFULEtBQUEsQ0FBQUwsS0FBQSxDQUFBSyxLQUFBLENBQUFULEtBQUEsQ0FBQWEsTUFBQTtBQUFBLElBQUFFLE9BQUE7QUFBQSxJQUFBQyxRQUFBO0FBQUEsSUFBQUMsSUFBQTtBQUFBLEVBQWIsRUFBcUJQLEtBQUEsQ0FBQU4sS0FBQSxDQUFBTSxLQUFBLENBQUFWLEtBQUEsQ0FBQWMsS0FBQTtBQUFBLElBQUFDLE9BQUE7QUFBQSxJQUFBQyxRQUFBO0FBQUEsSUFBQUMsSUFBQTtBQUFBLEVBQXJCIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGFzc2VydCA9IHJlcXVpcmUoJ2Fzc2VydCcpLFxuICAgIHRydXRoeSA9ICd0cnVlJyxcbiAgICBmYWxzeSA9ICdmYWxzZSc7XG5hc3NlcnQoZmFsc3kpO1xuYXNzZXJ0LmVxdWFsKHRydXRoeSwgZmFsc3kpO1xuIl19 42 | -------------------------------------------------------------------------------- /test/expected/example.js: -------------------------------------------------------------------------------- 1 | var _PowerAssertRecorder1 = function () { 2 | function PowerAssertRecorder() { 3 | this.captured = []; 4 | } 5 | PowerAssertRecorder.prototype._capt = function _capt(value, espath) { 6 | this.captured.push({ 7 | value: value, 8 | espath: espath 9 | }); 10 | return value; 11 | }; 12 | PowerAssertRecorder.prototype._expr = function _expr(value, source) { 13 | return { 14 | powerAssertContext: { 15 | value: value, 16 | events: this.captured 17 | }, 18 | source: source 19 | }; 20 | }; 21 | return PowerAssertRecorder; 22 | }(); 23 | var _rec1 = new _PowerAssertRecorder1(); 24 | var _rec2 = new _PowerAssertRecorder1(); 25 | var _rec3 = new _PowerAssertRecorder1(); 26 | var assert = require('power-assert'), truthy = 'true', falsy = 'false'; 27 | assert(_rec1._expr(_rec1._capt(falsy, 'arguments/0'), { 28 | content: 'assert(falsy)', 29 | filepath: 'test/fixtures/example.js', 30 | line: 4 31 | })); 32 | assert.equal(_rec2._expr(_rec2._capt(truthy, 'arguments/0'), { 33 | content: 'assert.equal(truthy, falsy)', 34 | filepath: 'test/fixtures/example.js', 35 | line: 5 36 | }), _rec3._expr(_rec3._capt(falsy, 'arguments/1'), { 37 | content: 'assert.equal(truthy, falsy)', 38 | filepath: 'test/fixtures/example.js', 39 | line: 5 40 | })); 41 | -------------------------------------------------------------------------------- /test/fixtures/customized.js: -------------------------------------------------------------------------------- 1 | var empower = require('empower'), 2 | formatter = require('power-assert-formatter'), 3 | busterAssertions = require("buster-assertions"), 4 | refute = empower(busterAssertions.refute, formatter(), { targetMethods: { oneArg: ['isNull'], twoArgs: ['same'] } }), 5 | truthy = 'true', 6 | falsy = 'false'; 7 | refute(truthy); 8 | refute.isNull(falsy); 9 | refute.same(truthy, falsy); 10 | -------------------------------------------------------------------------------- /test/fixtures/example.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'), 2 | truthy = 'true', 3 | falsy = 'false'; 4 | assert(falsy); 5 | assert.equal(truthy, falsy); 6 | -------------------------------------------------------------------------------- /test/fixtures/syntax-error.js: -------------------------------------------------------------------------------- 1 | var assert = require('power-assert'), 2 | truthy = 'true', 3 | falsy = 'false'; 4 | assert(falsy); 5 | assert.equal(truthy, // falsy); // SYNTAX ERROR! 6 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | /*global describe, it*/ 2 | "use strict"; 3 | 4 | delete require.cache[require.resolve('../')]; 5 | 6 | var fs = require("fs"); 7 | var es = require("event-stream"); 8 | var assert = require("assert"); 9 | var gutil = require("gulp-util"); 10 | var convert = require('convert-source-map'); 11 | var espower = require("../"); 12 | 13 | describe("gulp-espower", function () { 14 | 15 | describe("should produce expected file via buffer", function () { 16 | var stream, srcFile, expectedFile; 17 | beforeEach(function () { 18 | stream = espower(); 19 | srcFile = new gutil.File({ 20 | path: process.cwd() + "/test/fixtures/example.js", 21 | cwd: process.cwd(), 22 | base: process.cwd() + "/test/fixtures", 23 | contents: fs.readFileSync("test/fixtures/example.js") 24 | }); 25 | expectedFile = new gutil.File({ 26 | path: process.cwd() + "/test/expected/example.js", 27 | cwd: process.cwd(), 28 | base: process.cwd() + "/test/expected", 29 | contents: fs.readFileSync("test/expected/example.js") 30 | }); 31 | }); 32 | describe('without upstream sourceMap', function () { 33 | it("produce code without sourceMap", function (done) { 34 | stream.on("error", function(err) { 35 | assert(err); 36 | done(err); 37 | }); 38 | stream.on("data", function (newFile) { 39 | assert(newFile); 40 | assert(newFile.contents); 41 | assert(expectedFile.contents); 42 | assert.equal(newFile.contents.toString() + '\n', expectedFile.contents.toString()); 43 | assert(! newFile.sourceMap); 44 | done(); 45 | }); 46 | stream.write(srcFile); 47 | stream.end(); 48 | }); 49 | }); 50 | describe('with upstream sourceMap', function () { 51 | beforeEach(function () { 52 | srcFile.sourceMap = { 53 | version : 3, 54 | file: srcFile.relative, 55 | names: [], 56 | mappings: '', 57 | sources: [srcFile.relative], 58 | sourcesContent: [srcFile.contents.toString()] 59 | }; 60 | }); 61 | it("push file.sourceMap to downstream", function (done) { 62 | stream.on("error", function(err) { 63 | assert(err); 64 | done(err); 65 | }); 66 | stream.on("data", function (newFile) { 67 | assert(newFile); 68 | assert(newFile.contents); 69 | assert.equal(newFile.contents.toString() + '\n', expectedFile.contents.toString()); 70 | assert(newFile.sourceMap); 71 | assert.deepEqual(newFile.sourceMap, { 72 | version: 3, 73 | sources: [ 74 | 'example.js' 75 | ], 76 | names: [ 77 | '_PowerAssertRecorder1', 78 | 'PowerAssertRecorder', 79 | 'captured', 80 | 'prototype', 81 | '_capt', 82 | 'value', 83 | 'espath', 84 | 'push', 85 | '_expr', 86 | 'source', 87 | 'powerAssertContext', 88 | 'events', 89 | '_rec1', 90 | '_rec2',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AAM,KAAA,CAAAV,KAAA,CAAAc,KAAA;AAAA,IAAAC,OAAA;AAAA,IAAAC,QAAA;AAAA,IAAAC,IAAA;AAAA,EAArB', 102 | file: 'example.js', 103 | sourcesContent: [ 'var assert = require(\'assert\'),\n truthy = \'true\',\n falsy = \'false\';\nassert(falsy);\nassert.equal(truthy, falsy);\n' ] 104 | }); 105 | done(); 106 | }); 107 | stream.write(srcFile); 108 | stream.end(); 109 | }); 110 | }); 111 | }); 112 | 113 | 114 | 115 | describe("custom options", function (done) { 116 | var stream, srcFile, expectedFile; 117 | beforeEach(function () { 118 | stream = espower({ 119 | patterns: [ 120 | 'refute(actual, [message])', 121 | 'refute.same(actual, expected, [message])', 122 | 'refute.isNull(object, [message])' 123 | ] 124 | }); 125 | srcFile = new gutil.File({ 126 | path: process.cwd() + "/test/fixtures/customized.js", 127 | cwd: process.cwd(), 128 | base: process.cwd() + "/test/fixtures", 129 | contents: fs.readFileSync("test/fixtures/customized.js") 130 | }); 131 | expectedFile = new gutil.File({ 132 | path: process.cwd() + "/test/expected/example.js", 133 | cwd: process.cwd(), 134 | base: process.cwd() + "/test/expected", 135 | contents: fs.readFileSync("test/expected/customized.js") 136 | }); 137 | }); 138 | describe('without upstream sourceMap', function () { 139 | it("produce code without sourceMap", function (done) { 140 | stream.on("error", function(err) { 141 | assert(err); 142 | done(err); 143 | }); 144 | stream.on("data", function (newFile) { 145 | assert(newFile); 146 | assert(newFile.contents); 147 | assert.equal(newFile.contents.toString() + '\n', expectedFile.contents.toString()); 148 | assert(! newFile.sourceMap); 149 | done(); 150 | }); 151 | stream.write(srcFile); 152 | stream.end(); 153 | }); 154 | }); 155 | describe('with upstream sourceMap', function () { 156 | beforeEach(function () { 157 | srcFile.sourceMap = { 158 | version : 3, 159 | file: srcFile.relative, 160 | names: [], 161 | mappings: '', 162 | sources: [srcFile.relative], 163 | sourcesContent: [srcFile.contents.toString()] 164 | }; 165 | }); 166 | it("push file.sourceMap to downstream", function (done) { 167 | stream.on("error", function(err) { 168 | assert(err); 169 | done(err); 170 | }); 171 | stream.on("data", function (newFile) { 172 | assert(newFile); 173 | assert(newFile.contents); 174 | assert.equal(newFile.contents.toString() + '\n', expectedFile.contents.toString()); 175 | assert(newFile.sourceMap); 176 | assert.deepEqual(newFile.sourceMap, { 177 | version: 3, 178 | sources: [ 179 | 'customized.js' 180 | ], 181 | names: [ 182 | '_PowerAssertRecorder1', 183 | 'PowerAssertRecorder', 184 | 'captured', 185 | 'prototype', 186 | '_capt', 187 | 'value', 188 | 'espath', 189 | 'push', 190 | '_expr', 191 | 'source', 192 | 'powerAssertContext', 193 | 'events', 194 | '_rec1', 195 | '_rec2', 196 | '_rec3', 197 | '_rec4', 198 | 'empower', 199 | 'require', 200 | 'formatter', 201 | 'busterAssertions', 202 | 'refute', 203 | 'targetMethods', 204 | 'oneArg', 205 | 'twoArgs', 206 | 'truthy', 207 | 'falsy', 208 | 'content', 209 | 'filepath', 210 | 'line', 211 | 'isNull', 212 | 'same' 213 | ], 214 | mappings: 'AAAA,IAAAA,qBAAA;AAAA,aAAAC,mBAAA;AAAA,aAAAC,QAAA;AAAA;AAAA,IAAAD,mBAAA,CAAAE,SAAA,CAAAC,KAAA,YAAAA,KAAA,CAAAC,KAAA,EAAAC,MAAA;AAAA,aAAAJ,QAAA,CAAAK,IAAA;AAAA,YAAAF,KAAA,EAAAA,KAAA;AAAA,YAAAC,MAAA,EAAAA,MAAA;AAAA;AAAA,eAAAD,KAAA;AAAA;AAAA,IAAAJ,mBAAA,CAAAE,SAAA,CAAAK,KAAA,YAAAA,KAAA,CAAAH,KAAA,EAAAI,MAAA;AAAA;AAAA,YAAAC,kBAAA;AAAA,gBAAAL,KAAA,EAAAA,KAAA;AAAA,gBAAAM,MAAA,OAAAT,QAAA;AAAA;AAAA,YAAAO,MAAA,EAAAA,MAAA;AAAA;AAAA;AAAA,WAAAR,mBAAA;AAAA;AAMO,IAAAW,KAAA,OAAAZ,qBAAA,GANP;AAOc,IAAAa,KAAA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ert-formatter\'),\n busterAssertions = require("buster-assertions"),\n refute = empower(busterAssertions.refute, formatter(), { targetMethods: { oneArg: [\'isNull\'], twoArgs: [\'same\'] } }),\n truthy = \'true\',\n falsy = \'false\';\nrefute(truthy);\nrefute.isNull(falsy);\nrefute.same(truthy, falsy);\n' ] 217 | }); 218 | done(); 219 | }); 220 | stream.write(srcFile); 221 | stream.end(); 222 | }); 223 | }); 224 | }); 225 | 226 | 227 | it('should produce expected file via stream', function (done) { 228 | var stream = espower(); 229 | var srcStream = new gutil.File({ 230 | path: process.cwd() + '/test/fixtures/example.js', 231 | cwd: process.cwd(), 232 | base: process.cwd() + '/test/fixtures', 233 | contents: fs.createReadStream('test/fixtures/example.js') 234 | }); 235 | var expectedFile = new gutil.File({ 236 | path: process.cwd() + '/test/expected/example.js', 237 | cwd: process.cwd(), 238 | base: process.cwd() + '/test/expected', 239 | contents: fs.readFileSync('test/expected/example-with-sourcemap.js') 240 | }); 241 | stream.on('error', function(err) { 242 | assert(err); 243 | done(); 244 | }); 245 | stream.on('data', function (newFile) { 246 | assert(newFile); 247 | assert(newFile.contents); 248 | newFile.contents.pipe(es.wait(function(err, data) { 249 | assert(!err); 250 | assert.equal(data.toString('utf-8'), String(expectedFile.contents)); 251 | done(); 252 | })); 253 | }); 254 | stream.write(srcStream); 255 | stream.end(); 256 | }); 257 | 258 | 259 | describe('should emit error when the file has a syntax error', function () { 260 | it('when file is Buffer', function (done) { 261 | var stream = espower(); 262 | var srcFile = new gutil.File({ 263 | path: process.cwd() + "/test/fixtures/syntax-error.js", 264 | cwd: process.cwd(), 265 | base: process.cwd() + "/test/fixtures", 266 | contents: fs.readFileSync("test/fixtures/syntax-error.js") 267 | }); 268 | assert.doesNotThrow(function() { 269 | stream.on("error", function(err) { 270 | assert(err); 271 | done(); 272 | }); 273 | stream.write(srcFile); 274 | stream.end(); 275 | }); 276 | }); 277 | it('when file is Stream', function (done) { 278 | var stream = espower(); 279 | var srcStream = new gutil.File({ 280 | path: process.cwd() + "/test/fixtures/syntax-error.js", 281 | cwd: process.cwd(), 282 | base: process.cwd() + "/test/fixtures", 283 | contents: fs.createReadStream("test/fixtures/syntax-error.js") 284 | }); 285 | assert.doesNotThrow(function() { 286 | stream.on("error", function(err) { 287 | assert(err); 288 | done(); 289 | }); 290 | stream.write(srcStream); 291 | stream.end(); 292 | }); 293 | }); 294 | }); 295 | }); 296 | --------------------------------------------------------------------------------