babel-plugin-espower
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,9 @@ | ||
### [1.0.1](https://github.com/power-assert-js/babel-plugin-espower/releases/tag/v1.0.1) (2015-11-07) | ||
#### Bug Fixes | ||
* pin espower dependency to >=1.0.0 <=1.2.0 since there was a little breaking change ([6420b3dc](https://github.com/power-assert-js/babel-plugin-espower/commit/6420b3dc49a00f731eebbee695c90be8f13d5e73), closes [#8](https://github.com/power-assert-js/babel-plugin-espower/issues/8)) | ||
## [1.0.0](https://github.com/power-assert-js/babel-plugin-espower/releases/tag/v1.0.0) (2015-05-25) | ||
@@ -2,0 +10,0 @@ |
@@ -8,8 +8,8 @@ 'use strict'; | ||
function traverseUp (ancestors, traversalPath) { | ||
ancestors.push(traversalPath.key); | ||
if (Array.isArray(traversalPath.container)) { // traversing array via TraversalContext#visitMultiple | ||
var parentNode = traversalPath.parent; | ||
function traverseUp (ancestors, nodePath) { | ||
ancestors.push(nodePath.key); | ||
if (Array.isArray(nodePath.container)) { // traversing array via TraversalContext#visitMultiple | ||
var parentNode = nodePath.parent; | ||
var currentTraversingKey = find(types.VISITOR_KEYS[parentNode.type], function (key) { | ||
return parentNode[key] === traversalPath.container; // searching for current key in parentNode | ||
return parentNode[key] === nodePath.container; // searching for current key in parentNode | ||
}); | ||
@@ -20,10 +20,10 @@ if (currentTraversingKey) { // ex. 'arguments' in CallExpression | ||
} | ||
if (traversalPath.parentPath) { | ||
traverseUp(ancestors, traversalPath.parentPath); | ||
if (nodePath.parentPath) { | ||
traverseUp(ancestors, nodePath.parentPath); | ||
} | ||
} | ||
return function estreePath (traversalPath) { | ||
return function estreePath (nodePath) { | ||
var ancestors = []; | ||
traverseUp(ancestors, traversalPath); | ||
traverseUp(ancestors, nodePath); | ||
ancestors.reverse(); | ||
@@ -30,0 +30,0 @@ return ancestors; |
@@ -8,5 +8,5 @@ 'use strict'; | ||
function enterTraversalPath (traversalPath, currentNode, parentNode, scope, file, matchers, esTreePath, options) { | ||
function enterNodePath (nodePath, currentNode, parentNode, scope, file, matchers, esTreePath, options) { | ||
var treePath; | ||
var currentKey = traversalPath.key; | ||
var currentKey = nodePath.key; | ||
var assertionVisitor = file.get('espowerAssertionVisitor'); | ||
@@ -17,3 +17,3 @@ if (assertionVisitor) { | ||
// MEMO: exit() will not be called when skip() is called | ||
traversalPath.skip(); | ||
nodePath.skip(); | ||
return; | ||
@@ -23,3 +23,3 @@ } | ||
// entering argument | ||
treePath = esTreePath(traversalPath); | ||
treePath = esTreePath(nodePath); | ||
assertionVisitor.enterArgument(currentNode, parentNode, treePath); | ||
@@ -35,3 +35,3 @@ } | ||
}, options); | ||
treePath = esTreePath(traversalPath); | ||
treePath = esTreePath(nodePath); | ||
assertionVisitor = new espower.AssertionVisitor(matcher, treePath, espowerOptions); | ||
@@ -44,4 +44,4 @@ assertionVisitor.enter(currentNode, parentNode); | ||
function exitTraversalPath (traversalPath, currentNode, parentNode, scope, file, esTreePath, options) { | ||
var currentKey = traversalPath.key; | ||
function exitNodePath (nodePath, currentNode, parentNode, scope, file, esTreePath, options) { | ||
var currentKey = nodePath.key; | ||
var resultTree = currentNode; | ||
@@ -53,3 +53,3 @@ var isTreeModified = false; | ||
} | ||
var treePath = esTreePath(traversalPath); | ||
var treePath = esTreePath(nodePath); | ||
if (assertionVisitor.isLeavingAssertion(treePath)) { | ||
@@ -75,4 +75,4 @@ // leaving assertion | ||
if (isTreeModified) { | ||
traversalPath.replaceWith(resultTree); | ||
traversalPath.skip(); | ||
nodePath.replaceWith(resultTree); | ||
nodePath.skip(); | ||
} | ||
@@ -95,6 +95,6 @@ } | ||
enter: function (currentNode, parentNode, scope, file) { | ||
enterTraversalPath(this, currentNode, parentNode, scope, file, matchers, esTreePath, opts); | ||
enterNodePath(this, currentNode, parentNode, scope, file, matchers, esTreePath, opts); | ||
}, | ||
exit: function (currentNode, parentNode, scope, file) { | ||
exitTraversalPath(this, currentNode, parentNode, scope, file, esTreePath, opts); | ||
exitNodePath(this, currentNode, parentNode, scope, file, esTreePath, opts); | ||
} | ||
@@ -101,0 +101,0 @@ }; |
{ | ||
"name": "babel-plugin-espower", | ||
"description": "Babel plugin for power-assert", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -13,4 +13,4 @@ "name": "Takuto Wada", | ||
"array-find": "^1.0.0", | ||
"escallmatch": "^1.4.1", | ||
"espower": "^1.0.0", | ||
"escallmatch": "^1.4.2", | ||
"espower": ">=1.0.0 <=1.2.0", | ||
"xtend": "^4.0.0" | ||
@@ -17,0 +17,0 @@ }, |
@@ -81,3 +81,3 @@ babel-plugin-espower | ||
```javascript | ||
require('babel-core/register')({ | ||
require('babel/register')({ | ||
only: /test\/tobe_instrumented/, | ||
@@ -96,2 +96,62 @@ plugins: ['babel-plugin-espower'], | ||
### with [babelify](https://github.com/babel/babelify) | ||
```javascript | ||
var fs = require('fs'); | ||
var browserify = require('browserify'); | ||
var babelify = require('babelify'); | ||
var glob = require('glob'), | ||
browserify({ entries: glob.sync('./test/*_test.js'), debug: true }) | ||
.transform(babelify.configure({ plugins: ['babel-plugin-espower'] })) | ||
.bundle() | ||
.on('error', function (err) { console.log('Error : ' + err.message); }) | ||
.pipe(fs.createWriteStream('all_test.js')); | ||
``` | ||
``` | ||
$ $(npm bin)/browserify -d -e ./test/*_test.js -t [ babelify --plugins babel-plugin-espower ] | ||
``` | ||
### with [babelify](https://github.com/babel/babelify) and [gulp](http://gulpjs.com/) | ||
```javascript | ||
var source = require('vinyl-source-stream'); | ||
var browserify = require('browserify'); | ||
var glob = require('glob'), | ||
gulp.task('build_test', function() { | ||
var files = glob.sync('./test/*_test.js'); | ||
var b = browserify({entries: files, debug: true}); | ||
b.transform(babelify.configure({ | ||
plugins: ['babel-plugin-espower'] | ||
})); | ||
return b.bundle() | ||
.pipe(source('all_test.js')) | ||
.pipe(gulp.dest('./build')); | ||
}); | ||
``` | ||
### with [babelify](https://github.com/babel/babelify) and [Karma](http://karma-runner.github.io) | ||
```javascript | ||
module.exports = function(config) { | ||
config.set({ | ||
frameworks: ['mocha', 'browserify'], | ||
files: [ | ||
"test/**/*.js" | ||
], | ||
preprocessors: { | ||
"test/**/*.js": "browserify" | ||
}, | ||
browserify: { | ||
debug: true, | ||
transform: [ | ||
['babelify', {plugins: ['babel-plugin-espower']}] | ||
] | ||
}, | ||
// ... | ||
``` | ||
EXAMPLE | ||
@@ -229,3 +289,3 @@ --------------------------------------- | ||
var createEspowerPlugin = require('babel-plugin-espower/create'); | ||
require('babel-core/register')({ | ||
require('babel/register')({ | ||
only: /test\/tobe_instrumented/, | ||
@@ -232,0 +292,0 @@ plugins: [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20849
337
+ Addedespower@1.2.0(transitive)
- Removedespower@1.3.2(transitive)
Updatedescallmatch@^1.4.2
Updatedespower@>=1.0.0 <=1.2.0