Skip to content

Instantly share code, notes, and snippets.

@dhoward
Last active April 7, 2017 16:35
Show Gist options
  • Save dhoward/8079cbca5c15e5cf0fe1 to your computer and use it in GitHub Desktop.
Save dhoward/8079cbca5c15e5cf0fe1 to your computer and use it in GitHub Desktop.
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
/* get all imports with the right local name and source */
.find(j.ImportDeclaration, {
specifiers: [{
local:{
name:"Helmet"
}
}],
source: {
value: "@nfl/gridiron/addons"
}
}).forEach(statement => {
/* replace with the new import */
j(statement).replaceWith(j.importDeclaration(
[
j.importDefaultSpecifier(j.identifier("Helmet"))
],
j.literal("react-helmet")
));
}).toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment