janet-lang / jpm

Janet Project Manager
MIT License
68 stars 22 forks source link

On windows shutil/create-dirs tries to create drives too #41

Closed kamisori closed 2 years ago

kamisori commented 2 years ago

I tried to install from d901 but it said i didnt have permission, even though i used an elevated prompt. here my patch:


diff --git a/jpm/shutil.janet b/jpm/shutil.janet
index ffca564..1efdef7 100644
--- a/jpm/shutil.janet
+++ b/jpm/shutil.janet
@@ -70,7 +70,12 @@
   "Create all directories needed for a file (mkdir -p)."
   [dest]
   (def segs (peg/match path-splitter dest))
-  (for i 1 (length segs)
+  # if on windows, if segment ends in a colon: probably a drive: probably safe to skip
+  (for i (if (= (os/which) :windows)
+            (if (string/has-suffix? ":" (first segs))
+              2
+              1)
+            1) (length segs)
     (def path (string/join (slice segs 0 i) "/"))
     (unless (empty? path) (os/mkdir path))))
pepe commented 2 years ago

I guess this was addressed in 439b795e33ed6db2de907c97e002c4849f75f575 and can be closed.

kamisori commented 2 years ago

indeed

though i will open another ticket for where to put the manuals on windows. "copying jpm.1 to /usr/local/share/man/man1..." is just silly on windows