moroshko / react-scanner

Extract React components and props usage from code.
MIT License
563 stars 40 forks source link

feat: allow running programmatically #54

Closed mihkeleidast closed 1 year ago

mihkeleidast commented 1 year ago

Resolves #45.

We have this need as well, currently we're setting some process.env variables dynamically to change the config on the go. Running programmatically would make the code much easier to follow.

moroshko commented 1 year ago

Thanks for this @mihkeleidast! Can we return the output when outputTo is not specified so one could process the results?

const output = await scanner.run(config)
mihkeleidast commented 1 year ago

@moroshko thanks for the feedback, I added returning the output from the function, plus a couple of tests as well. The CI seems to be failing on test coverage, though in my machine it succeeds - any idea what's up with that?

mihkeleidast commented 1 year ago

Seems like CI runs on Node 12, if I use it locally, it also fails on some weird lines, like the final } of the run function, which I do not really know how to fix. It does not seem to fail on Node 14. As Node 12 is EOL, could we update CI to use Node 14 instead?

moroshko commented 1 year ago

Sure, feel free to upgrade to node 14. I'll be fine with node 16 as well.

mihkeleidast commented 1 year ago

@moroshko done, updated to Node 16, all green now!

moroshko commented 1 year ago

Published as 1.1.0. Thanks @mihkeleidast for your contribution!