1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Remove resolver element in path tuple.

Try to simplify module/paths back to how it used to be.
This commit is contained in:
Calvin Rose 2019-05-25 17:27:56 -04:00
parent 840610facf
commit 11998b3913
2 changed files with 11 additions and 9 deletions

View File

@ -20,9 +20,10 @@
(defn- check-http-url (defn- check-http-url
[path] [path]
(or (string/has-prefix? "http://" path) (if (or (string/has-prefix? "http://" path)
(string/has-prefix? "https://" path))) (string/has-prefix? "https://" path))
path))
# Add the module loader and path tuple to right places # Add the module loader and path tuple to right places
(array/push module/paths ["HTTP" :janet-http check-http-url identity]) (array/push module/paths [check-http-url :janet-http])
(put module/loaders :janet-http load-url) (put module/loaders :janet-http load-url)

View File

@ -1588,7 +1588,7 @@
require should load files found at these paths.\n\nA tuple can also require should load files found at these paths.\n\nA tuple can also
contain a third element, specifying a filter that prevents module/find contain a third element, specifying a filter that prevents module/find
from searching that path template if the filter doesn't match the input from searching that path template if the filter doesn't match the input
path." path. The filter is often a file extension, including the period."
@[[":all:" :source ".janet"] @[[":all:" :source ".janet"]
[":all:" :native (if (= (os/which) :windows) ".dll" ".so")] [":all:" :native (if (= (os/which) :windows) ".dll" ".so")]
[":all:" :image ".jimage"] [":all:" :image ".jimage"]
@ -1651,10 +1651,10 @@
(def parts (string/split "/" path)) (def parts (string/split "/" path))
(def name (last parts)) (def name (last parts))
(var ret nil) (var ret nil)
(each [p mod-kind checker resolver] module/paths (each [p mod-kind checker] module/paths
(when (mod-filter checker path) (when (mod-filter checker path)
(if resolver (if (function? p)
(when-let [res (resolver path)] (when-let [res (p path)]
(set ret [res mod-kind]) (set ret [res mod-kind])
(break)) (break))
(do (do
@ -1664,8 +1664,9 @@
(break)))))) (break))))))
(if ret ret (if ret ret
(let [expander (fn [[t _ chk]] (let [expander (fn [[t _ chk]]
(when (mod-filter chk path) (when (string? t)
(expand-path-name t name path))) (when (mod-filter chk path)
(expand-path-name t name path))))
paths (filter identity (map expander module/paths)) paths (filter identity (map expander module/paths))
str-parts (interpose "\n " paths)] str-parts (interpose "\n " paths)]
[nil (string "could not find module " path ":\n " ;str-parts)]))) [nil (string "could not find module " path ":\n " ;str-parts)])))