Glad I could help :)
El 15/03/2014 16:30, "Nick Featch" <[email protected]> escribió:
> On Friday, 14 March 2014 09:04:51 UTC, Joaquín Oltra Hernández wrote:
> > Yes, they are the same and can be used interchangeably.
> >
> > I've tried it and it works without any problem.
> >
> > ClojureScript:cljs.user> (def spawn (.-spawn (js/require
> "child_process")))
> >
> >
> > #<function (file /*, args, options*/) {
> > ...
> > ClojureScript:cljs.user> (let [p (spawn "ls" #js["-l"])]
> > (.on (.-stdout p) "data" println))
> > #<[object Object]>
> >
> >
> > #<total 1064
> > -rw-r--r-- 1 jkn staff 1817 Feb 5 13:27 README.md
> > drwxr-xr-x 3 jkn staff 102 Feb 6 10:53 checkouts
> > -rw-r--r-- 1 jkn staff 536522 Feb 5 13:27 cljs_node_lighttable.js
> > -rw-r--r-- 1 jkn staff 830 Feb 5 13:27 project.clj
> >
> >
> > drwxr-xr-x 3 jkn staff 102 Feb 5 13:27 src
> > drwxr-xr-x 4 jkn staff 136 Feb 10 15:04 target
> > >
> >
> >
> >
> >
> > On Thu, Mar 13, 2014 at 6:03 PM, Nick Featch <[email protected]> wrote:
> >
> >
> >
> > 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 a topic in the
> Google Groups "ClojureScript" group.
> >
> > To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojurescript/TObqicBxmKQ/unsubscribe.
> >
> > To unsubscribe from this group and all its topics, 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.
>
> Oh wow you've solved it, thank you. The way I'd imported is flawed, your
> way works.
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ClojureScript" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojurescript/TObqicBxmKQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>
--
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.