Open gomesalexandre opened 4 years ago
Actually, it seems that the third and last argument of Runner.run, options
, could let us inject data.
With that being said, I'm not a big fan of mixing concerns, in this case jscodeshift API options, and external data we want to inject. I would still vote for another argument
I would also like to hear more on this
Hey folks pretty sure you can pass arbitrary flags to jscodeshift and read them in your transform.
Try this jscodeshift --myarg foo --transform path/to/transform path/to/code
Now if you log the options argument you should see myarg
Hi! I'm currently trying to work with a transformer file that would receive injected data. It might be a non-standard usage of jscodeshift but this is the flow I'm currently trying to get working:
Although not documented, I've found how to use jscodeshift without the CLI (running the default export of
src/Runner.js
and reconstructing the arguments), but unfortunately, there is no way to pass data to the transformer file.It seems like passing data would be fairly trivial (https://github.com/gomesalexandre/jscodeshift/commit/ecf6c50968871b26435ae495642ede191c3ef93f).
Is that something that we would like to have? 🙏