diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index e2cdd82..3f3d015 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -30,29 +30,30 @@ (defn copy-dir - [source-dir target-path ignore-patterns] + [source-dir target-file ignore-patterns] (let [source-list (.list source-dir)] + (io/make-parents target-file) (doseq [f source-list] - (io/copy f (io/file target-path)))) - ) + (io/copy f target-file)))) (defn copy-resources [fs-prefix source-path target-path ignore-patterns] - (let [file (file-from-cp-or-filesystem fs-prefix source-path) - is-dir? (.isDirectory file)] + (let [source-file (file-from-cp-or-filesystem fs-prefix source-path) + target-file (io/file target-path source-path) + is-source-dir? (.isDirectory source-file)] (cond - (nil? file) + (nil? source-file) (throw (IllegalArgumentException. (str "resource " source-path " not found"))) - is-dir? - (copy-dir file target-path ignore-patterns) + is-source-dir? + (copy-dir source-file target-file ignore-patterns) :else - nil + nil ;(fs/copy src target) ))) (defn copy-resources-from-theme - [theme target] + [fs-prefix theme target] (let [source-path (str "templates/themes/" theme "/js") target-path (str target "/js")] - copy-resources source-path target-path)) + (copy-resources fs-prefix source-path target-path ""))) diff --git a/test/cryogen_core/classpath_able_io_test.clj b/test/cryogen_core/classpath_able_io_test.clj index 2b41ad2..07af03f 100644 --- a/test/cryogen_core/classpath_able_io_test.clj +++ b/test/cryogen_core/classpath_able_io_test.clj @@ -29,6 +29,8 @@ (deftest test-copy-resources-from-theme (is (do - (sut/copy-resources-from-theme theme target) - (and (verify-dir-exists (str target "/js")) - (verify-file-exists (str target "/js/dummy.js")))))) \ No newline at end of file + (sut/copy-resources-from-theme "./" theme target) + (and (verify-dir-exists + (str target "/templates/themes/bootstrap4-test/js")) + (verify-file-exists + (str target "/templates/themes/bootstrap4-test/js/dummy.js")))))) \ No newline at end of file