diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index 8c8d1de..f1b9510 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -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 (:require [clojure.java.io :as io] [clojure.string :as s])) -; TODO: loading from cpasspath results in nil even if file exists (defn file-from-cp [resource-path] (let [file-from-cp (io/file (io/resource resource-path))] @@ -28,18 +35,17 @@ from-fs (file-from-cp resource-path)))) - (defn copy-dir [source-dir target-dir ignore-patterns] (let [source-list (.list source-dir)] (doseq [f source-list] (let [target-file (io/file target-dir f) source-file (io/file source-dir f)] - (if (.isDirectory source-file) - (copy-dir source-file target-file ignore-patterns) + (if (.isFile source-file) (do (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 [fs-prefix source-path target-path ignore-patterns] diff --git a/test/cryogen_core/classpath_able_io_test.clj b/test/cryogen_core/classpath_able_io_test.clj index 0e12146..f7272e3 100644 --- a/test/cryogen_core/classpath_able_io_test.clj +++ b/test/cryogen_core/classpath_able_io_test.clj @@ -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 (:require [clojure.test :refer :all] [clojure.string :as s] @@ -15,6 +23,11 @@ (and (verify-file-exists 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 (is (sut/file-from-cp ".gitkeep")))