From d8841de18054d68c07b5e9c6cdec4a5e14d6ced3 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 16 Jan 2020 22:14:23 -0600 Subject: [PATCH] Address #188 Delete repo folder if clone fails. --- auxbin/jpm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/auxbin/jpm b/auxbin/jpm index cd3d4f76..ae52ff64 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -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 @{}