codemod
codemod copied to clipboard
[Question] How to list changed files?
Specifically the use case for this is to implement a replacement for the removal of --printer=prettier
I don't want to lint out entire project after each codemod, but I'm not sure what a less drastic option might be unless the files can be listed out?
You could do something like this:
# use "M" for modified files, or "??" for untracked, etc
git status --porcelain | awk 'match($1, "M") { print $2 }' | xargs codemod -p my-plugin
This could be pretty easily wrapped up in a shell alias or script:
alias changed-files="git status --porcelain | awk 'match($1, \"M\") { print $2 }'"
And used like so:
changed-files | xargs codemod -p my-plugin
I'm not sure whether something like this belongs in codemod
itself, like codemod --changed
or something. Why are you running it only on changed files?