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
[path]
(or (string/has-prefix? "http://" path)
(string/has-prefix? "https://" path)))
(if (or (string/has-prefix? "http://" path)
(string/has-prefix? "https://" path))
path))
# 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)

View File

@ -1588,7 +1588,7 @@
require should load files found at these paths.\n\nA tuple can also
contain a third element, specifying a filter that prevents module/find
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:" :native (if (= (os/which) :windows) ".dll" ".so")]
[":all:" :image ".jimage"]
@ -1651,10 +1651,10 @@
(def parts (string/split "/" path))
(def name (last parts))
(var ret nil)
(each [p mod-kind checker resolver] module/paths
(each [p mod-kind checker] module/paths
(when (mod-filter checker path)
(if resolver
(when-let [res (resolver path)]
(if (function? p)
(when-let [res (p path)]
(set ret [res mod-kind])
(break))
(do
@ -1664,8 +1664,9 @@
(break))))))
(if ret ret
(let [expander (fn [[t _ chk]]
(when (mod-filter chk path)
(expand-path-name t name path)))
(when (string? t)
(when (mod-filter chk path)
(expand-path-name t name path))))
paths (filter identity (map expander module/paths))
str-parts (interpose "\n " paths)]
[nil (string "could not find module " path ":\n " ;str-parts)])))