Skip to content

Commit a8c5326

Browse files
committed
feat(babel-plugin-empower-assert): support ImportDeclaration
1 parent fe5af7a commit a8c5326

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

index.js

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ module.exports = function (babel) {
5555
arg.set('value', 'power-assert');
5656
}
5757
}
58+
},
59+
ImportDeclaration: {
60+
enter: function (nodePath, pluginPass) {
61+
var source = nodePath.get('source');
62+
if (!(source.equals('value', 'assert'))) {
63+
return;
64+
}
65+
var firstSpecifier = nodePath.get('specifiers')[0];
66+
if (!firstSpecifier.isImportDefaultSpecifier()) {
67+
return;
68+
}
69+
var local = firstSpecifier.get('local');
70+
if (!(local.equals('name', 'assert'))) {
71+
return;
72+
}
73+
source.set('value', 'power-assert');
74+
}
5875
}
5976
}
6077
};

0 commit comments

Comments
 (0)