mirror of
https://github.com/janet-lang/janet
synced 2025-07-07 04:22:54 +00:00
Let jpm projects work better on windows.
Handle paths with normal, forward slashes better.
This commit is contained in:
parent
7bee204390
commit
a032529437
11
auxbin/jpm
11
auxbin/jpm
@ -184,6 +184,10 @@
|
|||||||
# OS and shell helpers
|
# OS and shell helpers
|
||||||
#
|
#
|
||||||
|
|
||||||
|
(def- path-splitter
|
||||||
|
"split paths on / and \\."
|
||||||
|
(peg/compile ~(any (* '(any (if-not (set `\/`) 1)) (set `\/`)))))
|
||||||
|
|
||||||
(def- filepath-replacer
|
(def- filepath-replacer
|
||||||
"Convert url with potential bad characters into a file path element."
|
"Convert url with potential bad characters into a file path element."
|
||||||
(peg/compile ~(% (any (+ (/ '(set "<>:\"/\\|?*") "_") '1)))))
|
(peg/compile ~(% (any (+ (/ '(set "<>:\"/\\|?*") "_") '1)))))
|
||||||
@ -229,7 +233,8 @@
|
|||||||
"Rename a janet symbol for embedding."
|
"Rename a janet symbol for embedding."
|
||||||
[path]
|
[path]
|
||||||
(->> path
|
(->> path
|
||||||
(string/replace-all sep "___")
|
(string/replace-all "\\" "___")
|
||||||
|
(string/replace-all "/" "___")
|
||||||
(string/replace-all ".janet" "")))
|
(string/replace-all ".janet" "")))
|
||||||
|
|
||||||
(defn- out-path
|
(defn- out-path
|
||||||
@ -596,7 +601,7 @@ int main(int argc, const char **argv) {
|
|||||||
(defn install-rule
|
(defn install-rule
|
||||||
"Add install and uninstall rule for moving file from src into destdir."
|
"Add install and uninstall rule for moving file from src into destdir."
|
||||||
[src destdir]
|
[src destdir]
|
||||||
(def parts (string/split sep src))
|
(def parts (peg/match path-splitter src))
|
||||||
(def name (last parts))
|
(def name (last parts))
|
||||||
(def path (string destdir sep name))
|
(def path (string destdir sep name))
|
||||||
(array/push (dyn :installed-files) path)
|
(array/push (dyn :installed-files) path)
|
||||||
@ -706,7 +711,7 @@ int main(int argc, const char **argv) {
|
|||||||
(install-rule main binpath)
|
(install-rule main binpath)
|
||||||
# Create a dud batch file when on windows.
|
# Create a dud batch file when on windows.
|
||||||
(when is-win
|
(when is-win
|
||||||
(def name (last (string/split sep main)))
|
(def name (last (peg/match path-splitter main)))
|
||||||
(def fullname (string binpath sep name))
|
(def fullname (string binpath sep name))
|
||||||
(def bat (string "@echo off\r\njanet \"" fullname "\" %*"))
|
(def bat (string "@echo off\r\njanet \"" fullname "\" %*"))
|
||||||
(def newname (string binpath sep name ".bat"))
|
(def newname (string binpath sep name ".bat"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user