1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-26 15:13:16 +00:00
Delete repo folder if clone fails.
This commit is contained in:
Calvin Rose 2020-01-16 22:14:23 -06:00
parent 23c7c3bf1c
commit d8841de180

View File

@ -588,16 +588,20 @@ int main(int argc, const char **argv) {
(rm manifest)
(print "Uninstalled."))
(defn- rimraf
"Hard delete directory tree"
[path]
(if is-win
# windows get rid of read-only files
(os/shell `rmdir /S /Q "` path `"`))
(rm path))
(defn clear-cache
"Clear the global git cache."
[]
(def cache (find-cache))
(print "clearing " cache "...")
(if is-win
# Git for windows decided that .git should be hidden and everything in it read-only.
# This means we can't delete things easily.
(os/shell (string `rmdir /S /Q "` cache `"`))
(rm cache)))
(rimraf cache))
(def- default-pkglist (or (os/getenv "JANET_PKGLIST") "https://github.com/janet-lang/pkgs.git"))
@ -632,7 +636,9 @@ int main(int argc, const char **argv) {
(when (mkdir module-dir)
(set fresh true)
(print "cloning repository " repo " to " module-dir)
(os/execute ["git" "clone" repo module-dir] :p))
(unless (zero? (os/execute ["git" "clone" repo module-dir] :p))
(rimraf module-dir)
(error (string "could not clone git dependency " repo))))
(def olddir (os/cwd))
(try
(with-dyns [:rules @{}