DEV Community

Adam Crockett πŸŒ€
Adam Crockett πŸŒ€

Posted on

RhinoJS runs node.js

A quick tip for the one or two people doing Google searches about RhinoJS, wishing, neh, hoping that thier product can adopt node.js somehow and have a modern scripting environment.

You have some options, it's not amazing but it's hope, you can use runCommand('node pathToFile.js', {opts}) fear not the documentation for this command is actually good! There we go, node.js like the respectful great grandson skateboards around doing the work for grandpa, the stuff that rhino just can't. Like run Babel and pipe the script to Rhino for running.

Once ran be sure to console.log from node, The stdout as captured by RhinoJS can be read as well as the process error count code.

Why

I managed to compile jasmine through Babel then bootstrap it and run it in rhino, I then wanted the tests to all be wrote in a modern way, I wanted rhino to run the test files without another build step🀘

So we have rhino patched to be a little more node like, running modern JavaScript and Jasmine with a little help from Node.js

How about the other way around?

Running Rhino from node, same principle, use child_process

I think that is how I'm going to handle testing, this rhino thing is a bit ass backwards, jest could exec a script in rhino and check the results, there would be some intervention but that's to extrapolate the results.

Anyway both ways need node.js so maybe I need to evaluate my use cases.. at runtime node didn't have to be a dependency I could just make do with 🦏

Top comments (0)