"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]
|
(:require [clojure.java.io :as io]
|
||||||
[clojure.string :as s]))
|
[clojure.string :as s]))
|
||||||
|
|
||||||
|
; TODO: loading from cpasspath results in nil even if file exists
|
||||||
(defn file-from-cp-or-filesystem
|
(defn file-from-cp-or-filesystem
|
||||||
[fs-prefix resource-path]
|
[fs-prefix resource-path]
|
||||||
(let [file-from-cp (io/file (io/resource "templates/themes/bootstrap4-test/js"))
|
(let [file-from-cp (io/file (io/resource resource-path))
|
||||||
file-from-fs (io/file "./test-resources/templates/themes/bootstrap4-test/js")]
|
file-from-fs (io/file (str fs-prefix resource-path))]
|
||||||
file-from-cp))
|
(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
|
(defn copy-dir
|
||||||
[source-path target-path ignored-files]
|
[source-path target-path ignored-files]
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
(.isDirectory (io/file path))))
|
(.isDirectory (io/file path))))
|
||||||
|
|
||||||
(deftest test-file-from-cp-or-filesystem
|
(deftest test-file-from-cp-or-filesystem
|
||||||
(is (do
|
(is
|
||||||
(sut/copy-resources-from-theme theme target)
|
(.exists (sut/file-from-cp-or-filesystem "./test-resources" "templates/themes/bootstrap4-test/js")))
|
||||||
(and (verify-dir-exists (str target "/js"))
|
(is
|
||||||
(verify-file-exists (str target "/js/dummy.js"))))))
|
(.exists (sut/file-from-cp-or-filesystem "./" ".gitignore"))))
|
||||||
|
|
||||||
(deftest test-copy-resources-from-theme
|
(deftest test-copy-resources-from-theme
|
||||||
(is (do
|
(is (do
|
||||||
|
|
Loading…
Reference in a new issue