Factor out UPDATE-SYMLINK.

This commit is contained in:
Brit Butler 2012-08-19 00:48:52 -04:00
parent 336763644d
commit 35ae75d03a

View file

@ -30,17 +30,19 @@
(render-indices)) (render-indices))
(deploy staging))) (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) (defun deploy (dir)
"Deploy DIR, updating the .prev and .curr symlinks." "Deploy DIR, updating the .prev and .curr symlinks."
(let ((new-build (namestring (app-path (format nil "generated/~a" (let ((new-build (app-path (format nil "generated/~a" (get-universal-time)))))
(get-universal-time)))))) (run-program "mv" (list dir (namestring new-build)))
(run-program "mv" (list dir new-build))
(when (probe-file (app-path ".prev")) (when (probe-file (app-path ".prev"))
(delete-files (read-symlink (app-path ".prev")) :recursive t)) (delete-files (read-symlink (app-path ".prev")) :recursive t))
(when (probe-file (app-path ".curr")) (when (probe-file (app-path ".curr"))
(let ((curr-build (namestring (read-symlink (app-path ".curr"))))) (update-symlink ".prev" (read-symlink (app-path ".curr"))))
(run-program "ln" (list "-sfn" curr-build ".prev")))) (update-symlink ".curr" new-build))
(run-program "ln" (list "-sfn" new-build ".curr")))
(setf (last-published) (last-commit))) (setf (last-published) (last-commit)))
(defun main () (defun main ()