From 35ae75d03a8260104d3be115f090e08c5f86f142 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Sun, 19 Aug 2012 00:48:52 -0400 Subject: [PATCH] Factor out UPDATE-SYMLINK. --- src/coleslaw.lisp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index bf79a02..efcf0ba 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -30,17 +30,19 @@ (render-indices)) (deploy staging))) +(defun update-symlink (name target) + "Update the symlink NAME to point to TARGET." + (run-program "ln" (list "-sfn" (namestring target) name))) + (defun deploy (dir) "Deploy DIR, updating the .prev and .curr symlinks." - (let ((new-build (namestring (app-path (format nil "generated/~a" - (get-universal-time)))))) - (run-program "mv" (list dir new-build)) + (let ((new-build (app-path (format nil "generated/~a" (get-universal-time))))) + (run-program "mv" (list dir (namestring new-build))) (when (probe-file (app-path ".prev")) (delete-files (read-symlink (app-path ".prev")) :recursive t)) (when (probe-file (app-path ".curr")) - (let ((curr-build (namestring (read-symlink (app-path ".curr"))))) - (run-program "ln" (list "-sfn" curr-build ".prev")))) - (run-program "ln" (list "-sfn" new-build ".curr"))) + (update-symlink ".prev" (read-symlink (app-path ".curr")))) + (update-symlink ".curr" new-build)) (setf (last-published) (last-commit))) (defun main ()