react-scanner icon indicating copy to clipboard operation
react-scanner copied to clipboard

feat: allow running programmatically

Open mihkeleidast opened this issue 3 years ago • 3 comments

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.

mihkeleidast avatar Sep 14 '22 06:09 mihkeleidast

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)

moroshko avatar Sep 17 '22 10:09 moroshko

@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 avatar Sep 19 '22 06:09 mihkeleidast

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?

mihkeleidast avatar Sep 19 '22 09:09 mihkeleidast

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

moroshko avatar Sep 23 '22 02:09 moroshko

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

mihkeleidast avatar Sep 23 '22 06:09 mihkeleidast

Published as 1.1.0. Thanks @mihkeleidast for your contribution!

moroshko avatar Sep 25 '22 04:09 moroshko