metasoarous / oz

Data visualizations in Clojure and ClojureScript using Vega and Vega-lite
Eclipse Public License 1.0
828 stars 74 forks source link

rebuilding when output file is missing (but input has not changed) #192

Open daslu opened 2 years ago

daslu commented 2 years ago

In the following session, I am removing the output HTML file, and recalling build! does not regenerate it. It would be nice to make it rebuild when the file is missing.

(following a Slack conversation: https://clojurians.slack.com/archives/C02PF73SETZ/p1659910092271159)

Assume we have a file dummy.clj:

(ns dummy)
(rand)

Then, let us render it with Oz, remove the result HTML, and try to render again.

clj -Sdeps '{:deps {metasoarous/oz {:mvn/version "2.0.0-alpha5"}}}'

$ (require '[oz.core :as oz])

$ (oz/build! [{:from "dummy.clj" :to "dummy.html"}] :live? false :lazy? false :view? false :port 1234)

$ (clojure.java.shell/sh "ls" "-l" "dummy.html") ; verify the HTML exists:
{:exit 0, :out "-rw-rw-r-- 1 daslu daslu 3011 Aug  8 01:02 dummy.html\n", :err ""}

$ (clojure.java.shell/sh "rm" "dummy.html") ; remove the HTML:

$ (oz/build! [{:from "dummy.clj" :to "dummy.html"}] :live? false :lazy? false :view? false :port 1234)

$ (clojure.java.shell/sh "ls" "-l" "dummy.html") ; verify the HTML does not exist:
{:exit 2, :out "", :err "ls: cannot access 'dummy.html': No such file or directory\n"}