This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-27
Channels
- # aws (3)
- # aws-lambda (8)
- # bangalore-clj (1)
- # beginners (155)
- # boot (13)
- # cider (88)
- # cljs-dev (3)
- # cljsrn (9)
- # clojure (120)
- # clojure-india (1)
- # clojure-italy (2)
- # clojure-norway (1)
- # clojure-romania (2)
- # clojure-russia (41)
- # clojure-spec (4)
- # clojure-uk (34)
- # clojurescript (68)
- # core-logic (16)
- # cursive (11)
- # data-science (9)
- # datomic (19)
- # dirac (6)
- # duct (20)
- # emacs (7)
- # events (2)
- # figwheel (4)
- # fulcro (12)
- # graphql (1)
- # hoplon (68)
- # klipse (1)
- # leiningen (7)
- # lumo (11)
- # off-topic (9)
- # onyx (114)
- # pedestal (4)
- # protorepl (15)
- # re-frame (60)
- # reagent (3)
- # ring (18)
- # shadow-cljs (15)
- # spacemacs (82)
(let [fname (timestamped-mainjs-fname)]
(comp
(gen-html :hiccup-var 'client.static.html/gen-index
:js-fname (timestamped-mainjs-fname))
(sift :move {#"main.js" fname})))
this piece of code here does not do what I think it does because timestamped-mainjs-fname is only called onceI need to call timestamped-mainjs-fname inside of ten-html (which I can easily do) I also need to "move sift inside gen-html|" -- that I don't know how to do
@qqq Isn't the problem that you're calling timestamped-mainjs-fname
twice in that code?
So what you pass into gen-html
is going to be different to what you pass into sift
?
@seancorfield: 1. that indeed is a bug, I was in the middle of refactoring. 2. I meant to write:
(let [fname (timestamped-mainjs-fname)]
(comp
(gen-html :hiccup-var 'client.static.html/gen-index
:js-fname fname)
(sift :move {#"main.js" fname})))
the problem with the current code is that (mainjs-fname) is only called once across all recompiles ; something due to boot tasks being functions that returns functions causes these steps to be 'executed once, returhning functions, which are then chained together'in particular, across different compiles, sift is moving "main.js" to "main_timestamp.js" ... but the timestamp is fixed, at the moment when the entire 'boot chain' is created
to fix this, I'm moving the (timestamped-mainjs-fname) call into gen-html ... but then, I somehow also need to 'move in the sift' -- which is non-trivial, as I can't just replace it with an io/copy since I'm dealing with filesets, and not the filesystem directly
Ah, right. So what you probably want is a task that creates the timestamp'd file name and stores it so that all downstream tasks can access it.
We use set-env!
to add such things to the task environment:
(with-pass-thru [fs]
(set-env! :my-project/js-filename (timestamped-mainjs-fname)))
as a separate task that you comp
into any pipeline that needs it and then retrieve it from the environment in other tasks.@seancorfield: due to the simplicity of my case (spitting out index.html + remaing main.js), I found I could just use the boot.core/mv task is the gist of your solution: there's some builtin env (global map of kw -> value? ) gen-html sets a field in the map move task, later on, reads from the env
Yup, Boot has an "environment" which is a mutable hash map that is accessible to all tasks.
It's a good way for tasks to "communicate" environmental stuff -- which a timestamped output file name is a good example.