On Wednesday, 12 March 2014 20:42:27 UTC, Joaquín Oltra wrote:
> Take a good look at the node.js docs, and show how you are swapping exec for
> spawn. They are different functions and they take different arguments. One
> difference for example is that the second argument in spawn is an array with
> the args and in exec is options for the execution.
>
> http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
>
> Another big difference is that exec gives you the results in the callback and
> spawn returns a ChildProcess object which is an event emitter, so it is not a
> matter of just swapping which function you are using.
>
> Look at the examples in the docs and translate them to cljs, it should be
> easy and there are plenty of them.
>
> Cheers
Hi thanks for your reply. Sorry my post did suggest I was simply just swapping
.exec for .spawn and hopping it would work ha ha. I've studied the docs and
tried to apply the differences as you can see below.
(def child-process (nd/require "child_process"))
(defn spawn [cmd arg opt] (.spawn child-process cmd arg opt))
(let [opt (utl/cmap->jobj {:cwd project-path})
proc (env/spawn "silk" (array "reload") opt)]
(.on (.-stdout proc) 'data' (fn [data]
(.log js/console data))))
The process runs (I can see it creating the file and directories I expect) but
no logging is preformed. Can you pass a clojurescript anonymous function to a
JavaScipt method?
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.