Skip to content

Instantly share code, notes, and snippets.

@rajasegar
Last active May 19, 2020 09:39
Show Gist options
  • Save rajasegar/1bf7aa20aed10e9390926762a23fab76 to your computer and use it in GitHub Desktop.
Save rajasegar/1bf7aa20aed10e9390926762a23fab76 to your computer and use it in GitHub Desktop.
Rename qunit modules codemod
// Press ctrl+space for code completion
export default function transformer(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const body = root.get().value.program.body;
let filter = {
callee: {
name: "module",
}
};
root.find(j.CallExpression, filter).forEach(path => {
if(options.from && path.value.arguments[0].value == options.from) {
path.value.arguments[0].value = options.to;
}
});
return root.toSource({ quote: 'single' });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment