wip
This commit is contained in:
parent
025b5c16a7
commit
c7006a8477
3 changed files with 54 additions and 21 deletions
|
@ -14,7 +14,8 @@
|
||||||
[io.aviso/pretty "0.1.37"]
|
[io.aviso/pretty "0.1.37"]
|
||||||
[me.raynes/fs "1.4.6"]
|
[me.raynes/fs "1.4.6"]
|
||||||
[pandect "0.6.1"]
|
[pandect "0.6.1"]
|
||||||
[selmer "1.12.17"]]
|
[selmer "1.12.17"]
|
||||||
|
[prismatic/schema "1.1.12"]]
|
||||||
:deploy-repositories [["snapshots" :clojars]
|
:deploy-repositories [["snapshots" :clojars]
|
||||||
["releases" :clojars]]
|
["releases" :clojars]]
|
||||||
:source-paths ["src"]
|
:source-paths ["src"]
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
(ns cryogen-core.classpath-able-io
|
(ns cryogen-core.classpath-able-io
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.java.io :as io]
|
||||||
[clojure.string :as s]))
|
[clojure.string :as s]
|
||||||
|
[schema.core :as s]))
|
||||||
|
|
||||||
(def public "resources/public")
|
(def public "resources/public")
|
||||||
|
|
||||||
|
@ -22,21 +23,32 @@
|
||||||
|
|
||||||
(defn filter-for-ignore-patterns
|
(defn filter-for-ignore-patterns
|
||||||
[ignore-patterns source-list]
|
[ignore-patterns source-list]
|
||||||
(filter #(not (re-matches ignore-patterns %)) source-list))
|
(filter #(not (re-matches ignore-patterns %)) source -list))
|
||||||
|
|
||||||
; TODO: Datenstruktur [s/Str]
|
; TODO: Datenstruktur [s/Str]
|
||||||
|
|
||||||
(defn delete-file-recursive
|
(s/defn get-file-paths-recursive :- [s/Str]
|
||||||
[folders]
|
[base-path :- s/Str
|
||||||
(when (not (empty? folders))
|
paths :- [s/Str]]
|
||||||
(let [file-to-work-with (first folders)
|
(loop [paths paths
|
||||||
; TODO: .list fehlt noch
|
result []]
|
||||||
file-list (filter #(.isFile %) file-to-work-with)
|
(when (not (empty? paths))
|
||||||
dir-list (filter #(not (.isFile %)) file-to-work-with)]
|
(let [path-to-work-with (first paths)
|
||||||
(doseq [file file-list] (io/delete-file file))
|
path-content (.list (io/file (str base-path "/" path-to-work-with)))
|
||||||
(when (not (empty? dir-list))
|
file-list (filter #(.isFile %) path-content)
|
||||||
(recur (drop 1 dir-list)))
|
dir-list (filter #(not (.isFile %)) path-content)]))))
|
||||||
(io/delete-file file-to-work-with))))
|
|
||||||
|
; (defn delete-file-recursive
|
||||||
|
; [folders]
|
||||||
|
; (when (not (empty? folders))
|
||||||
|
; (let [file-to-work-with (first folders)
|
||||||
|
; ; TODO: .list fehlt noch
|
||||||
|
; file-list (filter #(.isFile %) file-to-work-with)
|
||||||
|
; dir-list (filter #(not (.isFile %)) file-to-work-with)]
|
||||||
|
; (doseq [file file-list] (io/delete-file file))
|
||||||
|
; (when (not (empty? dir-list))
|
||||||
|
; (recur (drop 1 dir-list)))
|
||||||
|
; (io/delete-file file-to-work-with))))
|
||||||
|
|
||||||
(defn file-from-cp
|
(defn file-from-cp
|
||||||
[resource-path]
|
[resource-path]
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[cryogen-core.classpath-able-io :as sut]))
|
[cryogen-core.classpath-able-io :as sut]))
|
||||||
|
|
||||||
|
(set-fn-validation! true)
|
||||||
|
|
||||||
(def theme "bootstrap4-test")
|
(def theme "bootstrap4-test")
|
||||||
|
|
||||||
(def target "target/tmp")
|
(def target "target/tmp")
|
||||||
|
@ -23,12 +25,30 @@
|
||||||
(and (verify-file-exists path)
|
(and (verify-file-exists path)
|
||||||
(.isDirectory (io/file path))))
|
(.isDirectory (io/file path))))
|
||||||
|
|
||||||
(deftest test-wipe-public-folder
|
(deftest test-get-file-paths-recursive
|
||||||
(is
|
(is (=
|
||||||
(do
|
["js/dummy.js"]
|
||||||
(.mkdir (io/file target))
|
(sut/get-file-paths-recursive "templates/themes/bootstrap4-test" ["js/dummy.js"]))
|
||||||
(sut/delete-file-recursive (seq (io/file target)))
|
(is (=
|
||||||
(not (verify-dir-exists target)))))
|
["/css/dummy.css"
|
||||||
|
"css"
|
||||||
|
"/html/404.html"
|
||||||
|
"/html/403.html"
|
||||||
|
"/html"
|
||||||
|
"html"
|
||||||
|
"js/subdir/subdummy.js"
|
||||||
|
"js/subdir/test.js"
|
||||||
|
"js/subdir"
|
||||||
|
"js/dummy.js"
|
||||||
|
"js"]
|
||||||
|
(sut/get-file-paths-recursive "templates/themes/bootstrap4-test" [""])))))
|
||||||
|
|
||||||
|
; (deftest test-delete-file-recursive
|
||||||
|
; (is
|
||||||
|
; (do
|
||||||
|
; (.mkdir (io/file target))
|
||||||
|
; (sut/delete-file-recursive (seq (io/file target)))
|
||||||
|
; (not (verify-dir-exists target)))))
|
||||||
|
|
||||||
(deftest test-file-from-cp-or-filesystem
|
(deftest test-file-from-cp-or-filesystem
|
||||||
(is
|
(is
|
||||||
|
|
Loading…
Reference in a new issue