Skip to content

Instantly share code, notes, and snippets.

@leomelzer
Created November 7, 2019 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leomelzer/ebc9d199d7c6206271a7c463a6af3278 to your computer and use it in GitHub Desktop.
Save leomelzer/ebc9d199d7c6206271a7c463a6af3278 to your computer and use it in GitHub Desktop.
$ jscodeshift -t renameDefaultStory.js **/*.story.js
export const defaultStory = () => <StatusDot />;
export const Default = () => <StatusDot />;
/**
* @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