Created
January 11, 2022 08:44
-
-
Save arpitBhalla/61cd87e9597e5d66f3160a8dced36425 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** @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