It would be nice to have this to get closer into building larger codebases that build tools and execute them. For example a crude and horribly wrong implementation of system with require('child_process').exec(UTF8ToString(command), (e) => {}) will make icu install without the need of cross-compilation.
Agreed! This would be useful functionality to support. I can help if someone wants to implement this and has questions about the codebase.
Some questions:
1) I implemented the system myself in library.js, however is this the right place? Should we have own .js file for node that extends / overlays library.js?
2) If not, how should the node specific code be exposed in library.js?
3) Since child_process.exec is asynchronous operation, and system is synchronous, how can I block until exec is done?
library.js is probably fine, as other relevant code is in there.
Blocking is a trickier issue - I didn't realize some of those APIs were async! The best tool we have for that is asyncify. See for example emscripten_sleep which does an async call in JS, which looks synchronous to the outside. That does require building with asyncify, though - that has some downsides, but I think it's ok in this case (code size is larger, but in a local executable that's not as bad as on the web). For more info on that, see https://emscripten.org/docs/porting/asyncify.html
There is the sync version child_process.execSync, which should make the trick.
I'm willing to have a stab at this at some point. I have personal need for this.
https://github.com/emscripten-core/emscripten/pull/10547 should cover system function at least
Most helpful comment
There is the sync version
child_process.execSync, which should make the trick.