"mob next [ci-skip]"

This commit is contained in:
Jan Krebs 2019-12-13 15:25:52 +01:00
parent c7006a8477
commit 5ad40301bf
2 changed files with 26 additions and 22 deletions

View file

@ -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]

View file

@ -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