Created
July 1, 2016 10:43
-
-
Save jincod/fa1cdac75859e970febf9dd2ad7b119c to your computer and use it in GitHub Desktop.
Remove 'es6-promise' imports from legacy code. Using https://github.com/facebook/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
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
return j(file.source) | |
.find(j.ImportDeclaration, { | |
source: { | |
value: 'es6-promise' | |
} | |
}) | |
.filter(({node}) => node.specifiers.filter(value => value.local.name === 'Promise').length > 0) | |
.remove() | |
.toSource(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment