Created
September 14, 2017 10:25
-
-
Save rosswarren/3d340a78223e8452a737773d2efc180a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Press ctrl+space for code completion | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
return j(file.source) | |
.find(j.CallExpression) | |
.filter(x => x.node.callee.object && x.node.callee.object.name === "assert") | |
.filter(x => x.node.callee.property && x.node.callee.property.name === "isFalse") | |
.filter(x => x.node.arguments.length > 0 && x.node.arguments[0].property && x.node.arguments[0].property.name === "called") | |
.forEach(path => { | |
j(path).replaceWith( | |
j.callExpression(j.memberExpression(j.identifier("assert"), j.identifier("isTrue")), [ | |
j.memberExpression(path.node.arguments[0].object, j.identifier("notCalled")) | |
]) | |
); | |
}) | |
.toSource(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment