Created
November 7, 2019 08:54
-
-
Save leomelzer/ebc9d199d7c6206271a7c463a6af3278 to your computer and use it in GitHub Desktop.
$ jscodeshift -t renameDefaultStory.js **/*.story.js
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
export const defaultStory = () => <StatusDot />; |
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
export const Default = () => <StatusDot />; |
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
/** | |
* @param {import('@types/jscodeshift').FileInfo} fileInfo | |
* @param {import('@types/jscodeshift').API} api | |
*/ | |
module.exports = function(fileInfo, api) { | |
return api | |
.jscodeshift(fileInfo.source) | |
.find(api.jscodeshift.VariableDeclarator, { | |
id: { | |
name: 'defaultStory' | |
} | |
}) | |
.forEach(path => { | |
path.value.id.name = 'Default'; | |
}) | |
.toSource({ quote: 'single' }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment