filters now work with vectors intead of strings

This commit is contained in:
lukas 2020-03-06 18:38:18 +01:00
parent afeef539b5
commit ee937e05fe
2 changed files with 14 additions and 7 deletions

View file

@ -34,12 +34,19 @@
[ignore-patterns source-list]
(filter #(not (re-matches (re-pattern ignore-patterns) %)) source-list))
(defn filter-one-pattern
[ignore-patterns resources]
(if (not (empty? (:virtual-path (first resources))))
(filter #(not (re-matches ignore-patterns (:virtual-path %))) resources)
resources))
(defn filter-resources-for-ignore-patterns
[ignore-patterns resources]
(if ignore-patterns
(filter #(not (re-matches (re-pattern ignore-patterns) (:virtual-path %)))
resources)
resources))
(let [ignore-patterns (into [] ignore-patterns)
pattern (peek ignore-patterns)]
(if pattern
(filter-resources-for-ignore-patterns (pop ignore-patterns) (filter-one-pattern pattern resources))
resources)))
(defn resource-from-cp-or-fs ;:- Resource
[fs-prefix ;:- Prefix

View file

@ -28,7 +28,7 @@
(sut/get-distinct-markup-dirs
"./not-existing-get-from-cp"
"test_posts" "test_pages"
""))))))
[#""]))))))
(deftest test-create-dirs-from-markup-folders!
(is
@ -38,7 +38,7 @@
"./not-existing-get-from-cp"
"test_posts"
"test_pages"
target-tmp "")
target-tmp [#""])
(and (ftt/verify-dir-exists
(str target-tmp "/test_pages"))
(ftt/verify-dir-exists
@ -50,7 +50,7 @@
(is
(let [target-tmp "target/tmp-test-copy-resources-from-theme"]
(sut/delete-resources! target-tmp)
(sut/copy-resources-from-theme! "./" theme target-tmp "")
(sut/copy-resources-from-theme! "./" theme target-tmp [#""])
(and (ftt/verify-dir-exists
(str target-tmp "/js"))
(ftt/verify-file-exists