Skip to content

Commit 61dc73f

Browse files
committed
feat(babel-plugin-empower-assert): support AssignmentExpression
1 parent 5f9fe40 commit 61dc73f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

index.js

+23
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@
1313
module.exports = function (babel) {
1414
return {
1515
visitor: {
16+
AssignmentExpression: {
17+
enter: function (nodePath, pluginPass) {
18+
if (!nodePath.equals('operator', '=')) {
19+
return;
20+
}
21+
var left = nodePath.get('left');
22+
if (!left.isIdentifier()) {
23+
return;
24+
}
25+
if (!left.equals('name', 'assert')) {
26+
return;
27+
}
28+
var right = nodePath.get('right');
29+
if (!right.isCallExpression()) {
30+
return;
31+
}
32+
var callee = right.get('callee');
33+
var arg = right.get('arguments')[0];
34+
if (isRequireAssert(callee, arg)) {
35+
arg.set('value', 'power-assert');
36+
}
37+
}
38+
},
1639
VariableDeclarator: {
1740
enter: function (nodePath, pluginPass) {
1841
var id = nodePath.get('id');

0 commit comments

Comments
 (0)