facebook / facebook/jscodeshift

Inject data to transformer file?

Open
#363 3 comments 0 reactions 0 assignees View on GitHub
improvement
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

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:

1. Run an [inquirer](https://github.com/SBoudrias/Inquirer.js/) prompt
2. Collect user's Answers
3. Pass answers to jscodeshift transformer file
4. Parse the AST of some file (that the user will have chosen), and add/update/modify a node there, depending on user answers.

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? 🙏

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.