"mob next [ci-skip]"
This commit is contained in:
parent
c1594a035e
commit
3182421a5e
2 changed files with 17 additions and 7 deletions
|
@ -2,11 +2,21 @@
|
|||
(:require [clojure.java.io :as io]
|
||||
[clojure.string :as s]))
|
||||
|
||||
; TODO: loading from cpasspath results in nil even if file exists
|
||||
(defn file-from-cp-or-filesystem
|
||||
[fs-prefix resource-path]
|
||||
(let [file-from-cp (io/file (io/resource "templates/themes/bootstrap4-test/js"))
|
||||
file-from-fs (io/file "./test-resources/templates/themes/bootstrap4-test/js")]
|
||||
file-from-cp))
|
||||
(let [file-from-cp (io/file (io/resource resource-path))
|
||||
file-from-fs (io/file (str fs-prefix resource-path))]
|
||||
(try
|
||||
(when (.exists file-from-fs)
|
||||
file-from-fs)
|
||||
(catch Exception e
|
||||
(try (when (.exists file-from-cp)
|
||||
file-from-cp)
|
||||
(catch Exception e
|
||||
(throw (IllegalArgumentException.
|
||||
(str "resource " resource-path " neither found on classpath nor filesystem")))
|
||||
))))))
|
||||
|
||||
(defn copy-dir
|
||||
[source-path target-path ignored-files]
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
(.isDirectory (io/file path))))
|
||||
|
||||
(deftest test-file-from-cp-or-filesystem
|
||||
(is (do
|
||||
(sut/copy-resources-from-theme theme target)
|
||||
(and (verify-dir-exists (str target "/js"))
|
||||
(verify-file-exists (str target "/js/dummy.js"))))))
|
||||
(is
|
||||
(.exists (sut/file-from-cp-or-filesystem "./test-resources" "templates/themes/bootstrap4-test/js")))
|
||||
(is
|
||||
(.exists (sut/file-from-cp-or-filesystem "./" ".gitignore"))))
|
||||
|
||||
(deftest test-copy-resources-from-theme
|
||||
(is (do
|
||||
|
|
Loading…
Reference in a new issue