Closed lins05 closed 2 years ago
I like the idea! Of course it must keep working on both Planck and Node.
1 - Platform changes should live in an namespace of their own to be imported conditionally
2 - why the change in core?
3 - add checks through the main run script - whatever works in Planck should work in node
4 - add docs and check as per Deploy.md
1 - Platform changes should live in an namespace of their own to be imported conditionally
For clj/cljs we can use reader conditionals, but any tips how to detect whether it's nodejs or plank?
2 - why the change in core?
Because unlike jvm, a nodejs process doesn't necessarily exit after the main function is finished - it only exists when all the event loop has no more io callbacks to run. So it's very likely the main function sets up the event loop, and in such case cli-matic shall not call exit explicitly. Maybe I shall include this in code comment.
For clj/cljs we can use reader conditionals, but any tips how to detect whether it's nodejs or plank?
MAybe something like: https://github.com/l3nz/cli-matic/blob/e4303c722429371a324cdfdb0d9fc758c331d6d3/src/cli_matic/optionals.clj#L19
Because unlike jvm, a nodejs process doesn't necessarily exit after the main function is finished - it only exists when all the event loop has no more io callbacks to run. So it's very likely the main function sets up the event loop, and in such case cli-matic shall not call exit explicitly. Maybe I shall include this in code comment.
In general I would expect CLI-matic to shutdown at the end of the called function; there are a number of tricks we could use for waiting (eg core.async
) but they require external libraries and/or are not available in all cases. I am opening up a separate bug for a wrapper to defer termination - see #84.
BTW see #85
Would be awesome to see this working! Is there significant work to be done to get this to work?
Never completed, so I'm closing this without merging.
Right now when using from nodejs it fails to compile due to lack of "plank" namespace. I made some quick & dirty fix to make it work. If you think this could be of value to the project I can tidy up the code (e.g to make it work for both plank and node).