codemod icon indicating copy to clipboard operation
codemod copied to clipboard

[Question] How to create npx compatible codemod runners

Open Windvis opened this issue 3 years ago • 0 comments

I'm trying to create a simple codemod and I want to make it possible for end users to simply run that codemod once, without having to install it as a dependency first. Something like this would be optimal:

npx my-codemod-package-name file-paths

I think that should be possible by creating a bin setup in my package which runs codemod-cli behind the scenes, but I'm not sure how to set that up. Is there a public API that I can import and use in my bin script? Or should I execute the cli command from node code?

Any guidance is appreciated.

PS. I'm new to node / tooling development so sorry if this is a silly question.

Windvis avatar Jan 31 '22 11:01 Windvis