It's been mentioned on this group a few times before, and there are some open tickets:
https://github.com/nwjs/nw.js/issues/4875
But seemingly not a lot of traction on the issues.
From what I understand from reading around and doing my own experiments: fork is implemented by re-running a new instance nwjs, but presence of a .js file on the command causes it to switch to a "node-like" mode, which behaves like a typical node invocation. So far so good.
But here's where the main problem arises: the script status code is ignored completely.
Take the simple example below:
error.js, contains:
throw new Error("Bad Exit!")
Running with Node
node error.js
node error.js
/Users/carey/Documents/Work/Github/ChoiceScriptIDE/main/error.js:1
throw new Error("Bad Exit!")
Error: Bad Exit!
echo $?
127
Running with NWJS Helper (Renderer) -- as with .fork
..Frameworks/nwjs Framework.framework/Versions/97.0.4692.71/Helpers/nwjs Helper (Renderer).app/Contents/MacOS/nwjs Helper (Renderer) error.js
$?
0
The nwjs process doesn't propagate script errors correctly, as long it starts up a valid .JS file, it can do whatever it likes and there's no way to get feedback about that.
It's a little better if the script doesn't exist. From the command line you get an unhelpful error: [0122/150414.532056:FATAL:chrome_main_delegate.cc(1060)] Check failed: command_line.HasSwitch(switches::kProcessType) && !process_type.empty(). Helper application requires --type.
And exit code 133. Unfortunately, from fork itself, this results in null.
I don't know the NWJS codebase, or how it fits together with V8 and Chromium, but I would hope this is something that isn't too difficult to fix. I'd be happy to contribute, as best I can, but I don't really know where to start looking. node.cc and node.js maybe? Or is the whole problem a lot deeper rooted than I'm thinking?