Recently Written · git

coleslaw

Emacs mode for the "Coleslaw" site generator written in Common Lisp.

git clone https://github.com/equwal/coleslaw

Log | Files | Refs


commit c2a107cb3e81fa7d45fda4f7e00d8ea23a132f82
egao1980 <egao1980@gmail.com>
2020-04-14 18:34:47 +0100

Use robocopy on Windows

Rsync treats C:/ type path as remote and cowardly refuses to copy directories. Robocopy knows no fear.

 plugins/robocopy.lisp | 21 +++++++++++++++++++++
 src/coleslaw.lisp     |  5 ++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/plugins/robocopy.lisp b/plugins/robocopy.lisp
new file mode 100644
index 0000000..7e84521
--- /dev/null
+++ b/plugins/robocopy.lisp
@@ -0,0 +1,21 @@
+
+(defpackage :coleslaw-robocopy
+  (:use :cl)
+  (:import-from :coleslaw #:*config*
+                #:deploy
+                #:deploy-dir)
+  (:export #:enable))
+
+(in-package :coleslaw-robocopy)
+
+(defvar *args* nil)
+
+(defmethod deploy (staging)
+  (coleslaw::run-program
+   "(robocopy ~A ~A ~{~A~^ ~}) ^& IF %ERRORLEVEL% LEQ 1 exit 0"
+   (merge-pathnames staging)
+   (merge-pathnames (deploy-dir *config*))
+   *args*))
+
+(defun enable (&rest args)
+  (setf *args* args))
diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp
index 1517c66..1d380ac 100644
--- a/src/coleslaw.lisp
+++ b/src/coleslaw.lisp
@@ -35,7 +35,10 @@
                          (merge-pathnames "js" theme-dir)
                          (repo-path "static")))
         (when (probe-file dir)
-          (run-program "rsync --delete -raz ~a ." dir))))
+          (if (uiop:os-windows-p)
+              (run-program "(robocopy ~a ~a /MIR /IS) ^& IF %ERRORLEVEL% LEQ 1 exit 0" dir (path:basename dir))
+              (run-program "rsync --delete -raz ~a ." dir))
+          )))
     (do-subclasses (ctype content)
       (publish ctype))
     (do-subclasses (itype index)