codemod icon indicating copy to clipboard operation
codemod copied to clipboard

[Question] How to list changed files?

Open Nantris opened this issue 2 years ago • 1 comments

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?

Nantris avatar Jun 08 '22 01:06 Nantris

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?

eventualbuddha avatar Jun 08 '22 03:06 eventualbuddha