diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index 2f6ec4e..aae934b 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -8,7 +8,7 @@ (ns cryogen-core.classpath-able-io (:require [clojure.java.io :as io] - [clojure.string :as s] + [clojure.string :as st] [schema.core :as s])) (def public "resources/public") @@ -17,26 +17,13 @@ "Creates path from given parts, ignore empty elements" [& path-parts] (->> path-parts - (remove s/blank?) - (s/join "/") - (#(s/replace % #"/+" "/")))) + (remove st/blank?) + (st/join "/") + (#(st/replace % #"/+" "/")))) (defn filter-for-ignore-patterns [ignore-patterns source-list] - (filter #(not (re-matches ignore-patterns %)) source -list)) - -; TODO: Datenstruktur [s/Str] - -(s/defn get-file-paths-recursive :- [s/Str] - [base-path :- s/Str - paths :- [s/Str]] - (loop [paths paths - result []] - (when (not (empty? paths)) - (let [path-to-work-with (first paths) - path-content (.list (io/file (str base-path "/" path-to-work-with))) - file-list (filter #(.isFile %) path-content) - dir-list (filter #(not (.isFile %)) path-content)])))) + (filter #(not (re-matches ignore-patterns %)) source-list)) ; (defn delete-file-recursive ; [folders] @@ -75,6 +62,23 @@ from-fs (file-from-cp resource-path)))) +(s/defn get-file-paths-recursive :- [s/Str] + [fs-prefix :- s/Str + base-path :- s/Str + paths :- [s/Str]] + (loop [paths paths + result []] + (when (not (empty? paths)) + (let [path-to-work-with (first paths) + path-content (.list (io/file (file-from-cp-or-filesystem + fs-prefix + (str base-path "/" path-to-work-with)))) + file-list (filter #(.isFile (io/file %)) path-content) + dir-list (filter #(not (.isFile %)) path-content)] + (println path-content) + ;(println file-list) + (into result file-list))))) + (defn copy-file [source-file target-file] diff --git a/test/cryogen_core/classpath_able_io_test.clj b/test/cryogen_core/classpath_able_io_test.clj index 91e8e4e..4c794ac 100644 --- a/test/cryogen_core/classpath_able_io_test.clj +++ b/test/cryogen_core/classpath_able_io_test.clj @@ -8,11 +8,11 @@ (ns cryogen-core.classpath-able-io-test (:require [clojure.test :refer :all] - [clojure.string :as s] [clojure.java.io :as io] + [schema.core :as s] [cryogen-core.classpath-able-io :as sut])) -(set-fn-validation! true) +(s/set-fn-validation! true) (def theme "bootstrap4-test") @@ -28,7 +28,7 @@ (deftest test-get-file-paths-recursive (is (= ["js/dummy.js"] - (sut/get-file-paths-recursive "templates/themes/bootstrap4-test" ["js/dummy.js"])) + (sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"])) (is (= ["/css/dummy.css" "css" @@ -41,7 +41,7 @@ "js/subdir" "js/dummy.js" "js"] - (sut/get-file-paths-recursive "templates/themes/bootstrap4-test" [""]))))) + (sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" [""]))))) ; (deftest test-delete-file-recursive ; (is