Make a little file loader

This commit is contained in:
Scott Richmond 2022-05-24 18:52:32 -04:00
parent 96ef8f098f
commit d8d1bf0858
2 changed files with 14 additions and 1 deletions

View File

@ -3,7 +3,8 @@
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.11.1"]]
:dependencies [[org.clojure/clojure "1.11.1"]
[babashka/fs "0.1.6"]]
:plugins [[lein-cljfmt "0.8.0"]]
:repl-options {:init-ns ludus.core}
:main ludus.core

12
src/ludus/loader.clj Normal file
View File

@ -0,0 +1,12 @@
(ns ludus.loader
(:require [babashka.fs :as fs]))
(defn cwd [] (fs/cwd))
(defn load-import
([file] (-> file (fs/canonicalize) (fs/file) (slurp)))
([file from]
(load-import
(fs/path
(fs/parent (fs/canonicalize from))
(fs/path file)))))