]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.deploy.backend: clean the old deploy images automatically
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 26 Apr 2023 16:02:24 +0000 (09:02 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 26 Apr 2023 16:02:39 +0000 (09:02 -0700)
basis/tools/deploy/backend/backend.factor

index 6630e7f1adbc9eb62ebd3921a18f4c035cc513af..87a2b012a00cab823a602c1ea9d31b669ed320ad 100644 (file)
@@ -1,12 +1,14 @@
 ! Copyright (C) 2007, 2010 Slava Pestov.
 ! See https://factorcode.org/license.txt for BSD license.
+
 USING: accessors alien.libraries.finder assocs bootstrap.image
-hashtables io io.directories io.encodings.utf8 io.files
-io.files.temp io.launcher io.pathnames kernel make
-namespaces prettyprint sequences splitting system
-tools.deploy.config tools.deploy.config.editor
+combinators.short-circuit hashtables io io.directories
+io.encodings.utf8 io.files io.files.temp io.launcher
+io.pathnames kernel make namespaces prettyprint sequences
+splitting system tools.deploy.config tools.deploy.config.editor
 tools.deploy.embed vocabs.loader vocabs.metadata.resources
 webbrowser ;
+
 IN: tools.deploy.backend
 
 : copy-vm ( executable bundle-name -- vm-path )
@@ -130,3 +132,13 @@ t open-directory-after-deploy? set-global
 HOOK: deploy* os ( vocab -- )
 
 HOOK: deploy-path os ( vocab -- path )
+
+STARTUP-HOOK: [
+    ! clean the old staging images
+    vm-git-id "staging." my-arch-name ".txt" 3append
+    cache-file dup {
+        [ file-exists? not ]
+        [ utf8 file-contents pick = not ]
+    } 1|| [ delete-staging-images ] when
+    utf8 set-file-contents
+]