"Mob Session DONE [ci-skip]"

This commit is contained in:
jem 2019-12-06 16:37:24 +01:00
parent 6f2a28df22
commit e29c246e3b
2 changed files with 24 additions and 5 deletions

View file

@ -1,8 +1,15 @@
; Copyright (c) meissa. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(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]))
; TODO: loading from cpasspath results in nil even if file exists
(defn file-from-cp (defn file-from-cp
[resource-path] [resource-path]
(let [file-from-cp (io/file (io/resource resource-path))] (let [file-from-cp (io/file (io/resource resource-path))]
@ -28,18 +35,17 @@
from-fs from-fs
(file-from-cp resource-path)))) (file-from-cp resource-path))))
(defn copy-dir (defn copy-dir
[source-dir target-dir ignore-patterns] [source-dir target-dir ignore-patterns]
(let [source-list (.list source-dir)] (let [source-list (.list source-dir)]
(doseq [f source-list] (doseq [f source-list]
(let [target-file (io/file target-dir f) (let [target-file (io/file target-dir f)
source-file (io/file source-dir f)] source-file (io/file source-dir f)]
(if (.isDirectory source-file) (if (.isFile source-file)
(copy-dir source-file target-file ignore-patterns)
(do (do
(io/make-parents target-file) (io/make-parents target-file)
(io/copy f target-file))))))) (io/copy f target-file))
(recur source-file target-file ignore-patterns))))))
(defn copy-resources (defn copy-resources
[fs-prefix source-path target-path ignore-patterns] [fs-prefix source-path target-path ignore-patterns]

View file

@ -1,3 +1,11 @@
; Copyright (c) meissa. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns cryogen-core.classpath-able-io-test (ns cryogen-core.classpath-able-io-test
(:require [clojure.test :refer :all] (:require [clojure.test :refer :all]
[clojure.string :as s] [clojure.string :as s]
@ -15,6 +23,11 @@
(and (verify-file-exists path) (and (verify-file-exists path)
(.isDirectory (io/file path)))) (.isDirectory (io/file path))))
(deftest test-filter-for-ignore-patterns
(is (=
["file.js"]
(sut/filter-for-ignore-patterns #".*\\.ignore" ["file.js" "file.ignore"]))))
(deftest test-file-from-cp (deftest test-file-from-cp
(is (is
(sut/file-from-cp ".gitkeep"))) (sut/file-from-cp ".gitkeep")))