Created
January 16, 2019 01:28
-
-
Save davidtingsu/1550ae83aa05bc841efc59f384025c30 to your computer and use it in GitHub Desktop.
gist to add 'configure' to enzyme imports using jscodeshift
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
// https://astexplorer.net/#/gist/55b79bb6a2287057b4459d5ef87528a1/34173b57c114657bd47b0441ad35cb88037e7832 | |
// Press ctrl+space for code completion | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
return j(file.source) | |
.find(j.ImportDeclaration) | |
.forEach(importStatement => { | |
const specifiers = j(importStatement).find(j.ImportSpecifiers); | |
importStatement.node.specifiers.push(j.importSpecifier(j.identifier('configure'))); | |
/*j(path).replaceWith( | |
j.identifier(path.node.name.split('').reverse().join('')) | |
);*/ | |
return importStatement; | |
}) | |
.toSource(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment