Skip to content

Instantly share code, notes, and snippets.

@arpitBhalla
Created January 11, 2022 08:44
Show Gist options
  • Save arpitBhalla/61cd87e9597e5d66f3160a8dced36425 to your computer and use it in GitHub Desktop.
Save arpitBhalla/61cd87e9597e5d66f3160a8dced36425 to your computer and use it in GitHub Desktop.
/** @type {import('@types/jscodeshift/index').Transform} */
module.exports = function(file, api) {
const j = api.jscodeshift;
const rootProperties = {
type: "ImportDeclaration",
source: {
type: "Literal",
value: "react-native-elements",
},
};
function getTransform(path) {
const pkgName = (path.node.source.value).replace(
/react-native-elements(.*)/gm,
"@react-native-elements/themed/$1"
);
return j.importDeclaration(path.node.specifiers, j.literal(pkgName));
}
return j(file.source)
.find(j.ImportDeclaration, rootProperties)
.replaceWith(getTransform)
.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment