Fix file loading from REPL
This commit is contained in:
parent
f8322412b7
commit
5653912f0e
|
@ -336,11 +336,13 @@
|
||||||
|
|
||||||
(defn- interpret-import [ast ctx]
|
(defn- interpret-import [ast ctx]
|
||||||
(let [path (:path ast)
|
(let [path (:path ast)
|
||||||
name (:name ast)]
|
name (:name ast)
|
||||||
|
file (ludus-resolve :file ctx)
|
||||||
|
from (if (= ::not-found file) :cwd file)]
|
||||||
(if (contains? @ctx name)
|
(if (contains? @ctx name)
|
||||||
(throw (ex-info (str "Name " name " is alrady bound") {:ast ast}))
|
(throw (ex-info (str "Name " name " is alrady bound") {:ast ast}))
|
||||||
(let [source (try
|
(let [source (try
|
||||||
(loader/load-import path (ludus-resolve :file ctx))
|
(loader/load-import path from)
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(if (::loader/error (ex-data e))
|
(if (::loader/error (ex-data e))
|
||||||
(throw (ex-info (ex-message e) {:ast ast}))
|
(throw (ex-info (ex-message e) {:ast ast}))
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
([file from]
|
([file from]
|
||||||
(load-import
|
(load-import
|
||||||
(fs/path
|
(fs/path
|
||||||
(fs/parent (fs/canonicalize from))
|
(if (= from :cwd) (fs/cwd) (fs/parent (fs/canonicalize from)))
|
||||||
(fs/path file)))))
|
(fs/path file)))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user