Boot task to open a url in a browser

I’m trying to create a very dumb task that just opens a browser at the end of the build to avoid me to open it manually. Think “http://localhost:3000”. This url is served by boot-http and embeds the clojurescript I’m developing.

I’ve tried many variations of this, without success:

(require '[ :refer [browse-url]])

(deftask open-browser
  "Open a url in a web browser"
  [u url VAL str "url to open"]
  (with-post-wrap fileset
    (browse-url url)))

Tried with-pre-wrap, _ instead of fileset since I don’t use it at all, then positioning the task call in several places of the comp chain, that looks like this:

(deftask dev
  "Compile a standalone ready-to-use js file."
    (serve :dir "out") 
    (watch) ;; tried here
    (cljs-repl :nrepl-opts {:port 9099})
    (cljs :compiler-options {:options :elided})
    (open-browser "http://localhost:3000")
    (target :dir #{"out/js"}))) ;; tried here as the last task

Any help really appreciated for the lazy guy I am :smiley:

Not sure if that’s the issue but this should be

(open-browser :url "http://localhost:3000")
1 Like

Of course ! I feel alsmot ashamed for not having caught by myself haha.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.