(relativize-path path {:keys [output-dir source-map-path source-map relpaths], :as opts})
Relativize a path using :source-map-path if provided or the parent directory
otherwise.
Source
(defn relativize-path
"Relativize a path using :source-map-path if provided or the parent directory
otherwise."
[path {:keys [output-dir source-map-path source-map relpaths] :as opts}]
(let [bare-munged-path
(cond
(re-find #"\.jar!/" path)
(str (or source-map-path output-dir)
(second (string/split path #"\.jar!")))
:else
(str (or source-map-path output-dir)
"/" (get relpaths path)))]
(cond
source-map-path bare-munged-path
:else
(let [unrel-uri (-> bare-munged-path io/file .toURI)
sm-parent-uri (-> source-map io/file .getAbsoluteFile .getParentFile .toURI)]
(str (.relativize sm-parent-uri unrel-uri))))))