Skip to content

Instantly share code, notes, and snippets.

@jincod
Created July 1, 2016 10:43
Show Gist options
  • Save jincod/fa1cdac75859e970febf9dd2ad7b119c to your computer and use it in GitHub Desktop.
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
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