From c1594a035ed23a9ccebb9ceea22527f397fe9bbf Mon Sep 17 00:00:00 2001 From: jem Date: Tue, 3 Dec 2019 17:51:21 +0100 Subject: [PATCH] "Mob Session DONE [ci-skip]" --- src/cryogen_core/classpath_able_io.clj | 24 +++++++++----------- test/cryogen_core/classpath_able_io_test.clj | 6 +++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index 1331bdf..3dfb4c5 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -1,29 +1,27 @@ (ns cryogen-core.classpath-able-io (:require [clojure.java.io :as io] - [clojure.string :as s] - [me.raynes.fs :as fs])) + [clojure.string :as s])) + +(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)) (defn copy-dir [source-path target-path ignored-files] - (fs/mkdirs target-path) - (let [^java.io.FilenameFilter filename-filter (apply reject-re-filter ignored-files) - files (.listFiles (io/file source-path) filename-filter)] - (doseq [^java.io.File f files] - (let [out (io/file target-path (.getName f))] - (if (.isDirectory f) - (copy-dir f out ignored-files) - (io/copy f out)))))) + ) (defn copy-resources [source-path target-path] - (let [ignored-files []] + (let [ignored-files [] + source-file (io/file source-path)] (cond (not (.exists (io/file source-path))) (throw (IllegalArgumentException. (str "resource " source-path " not found"))) (.isDirectory (io/file source-path)) (copy-dir source-path target-path ignored-files) - :else - (fs/copy source-path target-path)))) + ))) (defn copy-resources-from-theme [theme target] diff --git a/test/cryogen_core/classpath_able_io_test.clj b/test/cryogen_core/classpath_able_io_test.clj index 313311d..2bcb3ea 100644 --- a/test/cryogen_core/classpath_able_io_test.clj +++ b/test/cryogen_core/classpath_able_io_test.clj @@ -15,6 +15,12 @@ (and (verify-file-exists path) (.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")))))) + (deftest test-copy-resources-from-theme (is (do (sut/copy-resources-from-theme theme target)