reduce redundancy
This commit is contained in:
parent
02598f1078
commit
d9951fced1
1 changed files with 11 additions and 4 deletions
|
@ -74,6 +74,13 @@
|
||||||
|
|
||||||
(defn current-path [])
|
(defn current-path [])
|
||||||
|
|
||||||
|
(defn user-dir []
|
||||||
|
(java.lang.System/getProperty "user.dir"))
|
||||||
|
|
||||||
|
(defn absolut-path
|
||||||
|
[& path-elements]
|
||||||
|
(Paths/get (user-dir) (into-array String path-elements)))
|
||||||
|
|
||||||
(defn path
|
(defn path
|
||||||
"Creates path from given parts, ignore empty elements"
|
"Creates path from given parts, ignore empty elements"
|
||||||
[& path-parts]
|
[& path-parts]
|
||||||
|
@ -116,7 +123,7 @@
|
||||||
base-path
|
base-path
|
||||||
resource-path]
|
resource-path]
|
||||||
(if (st/starts-with? fs-prefix "./")
|
(if (st/starts-with? fs-prefix "./")
|
||||||
(str (st/replace fs-prefix #"\./" (str (java.lang.System/getProperty "user.dir") "/")) "/" base-path "/" resource-path)
|
(str (st/replace fs-prefix #"\./" (str (user-dir) "/")) "/" base-path "/" resource-path)
|
||||||
(str fs-prefix "/" base-path "/" resource-path)))
|
(str fs-prefix "/" base-path "/" resource-path)))
|
||||||
|
|
||||||
(defn resource-from-cp-or-fs ; :- Resource
|
(defn resource-from-cp-or-fs ; :- Resource
|
||||||
|
@ -206,12 +213,12 @@
|
||||||
[short-path :- s/Str]
|
[short-path :- s/Str]
|
||||||
(let [resource-paths
|
(let [resource-paths
|
||||||
(reverse (get-resource-paths-recursive
|
(reverse (get-resource-paths-recursive
|
||||||
(str (java.lang.System/getProperty "user.dir") "/")
|
(str (user-dir) "/")
|
||||||
short-path
|
short-path
|
||||||
[""]
|
[""]
|
||||||
:from-cp false))]
|
:from-cp false))]
|
||||||
(doseq [resource-path resource-paths]
|
(doseq [resource-path resource-paths]
|
||||||
(Files/delete (Paths/get (URI. (str "file://" (java.lang.System/getProperty "user.dir") "/" short-path resource-path))))
|
(Files/delete (absolut-path short-path resource-path))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
; TODO: add ignore patterns filtering
|
; TODO: add ignore patterns filtering
|
||||||
|
@ -228,7 +235,7 @@
|
||||||
(throw (IllegalArgumentException. (str "resource " resource-paths ", "
|
(throw (IllegalArgumentException. (str "resource " resource-paths ", "
|
||||||
source-paths " not found")))
|
source-paths " not found")))
|
||||||
(doseq [resource-path resource-paths]
|
(doseq [resource-path resource-paths]
|
||||||
(let [target-file (Paths/get (URI. (str "file://" (java.lang.System/getProperty "user.dir") "/" target-path "/" resource-path)))
|
(let [target-file (absolut-path target-path resource-path)
|
||||||
source-file (path-from-cp-or-fs
|
source-file (path-from-cp-or-fs
|
||||||
fs-prefix
|
fs-prefix
|
||||||
base-path
|
base-path
|
||||||
|
|
Loading…
Reference in a new issue