Last active
May 19, 2020 09:39
-
-
Save rajasegar/1bf7aa20aed10e9390926762a23fab76 to your computer and use it in GitHub Desktop.
Rename qunit modules codemod
This file contains 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
// 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