]> code.delx.au - gnu-emacs-elpa/commitdiff
Cleanup dependency management.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 1 Mar 2015 19:10:32 +0000 (11:10 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 1 Mar 2015 19:10:32 +0000 (11:10 -0800)
Makefile
scripts/dependencies [new file with mode: 0644]
scripts/download-dependencies.el

index c26538257a28f039b58b6e4878e48ab1f630ef09..3a6a0be002a1ce4590571b65447d5db532c042b8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,8 @@ clean: uncompile
 
 ${DEPENDENCIES}:
        ${EMACS} -Q -batch \
-       -l scripts/download-dependencies.el
+       -l scripts/download-dependencies.el \
+       -f download-dependencies
 
 test: ${DEPENDENCIES}
        ${EMACS} -Q -batch \
diff --git a/scripts/dependencies b/scripts/dependencies
new file mode 100644 (file)
index 0000000..c2a9107
--- /dev/null
@@ -0,0 +1,2 @@
+https://raw.githubusercontent.com/mooz/js2-mode/master/js2-mode.el
+https://raw.githubusercontent.com/rejeep/ert-async.el/master/ert-async.el
index b4a82fc89b9a7d97c4bb0c0ef1818a111f520960..2ab24e2f496ffec421fa66f2632aaf88722bfc9f 100644 (file)
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-;; This script downloads some dependencies for development so they don't need to
-;; be version-controlled.
+;; Download dependencies for development.
+
+;; Dependencies don't need to be version-controlled. They are also
+;; bleeding-edge, which is good because that is what most MELPA users are using.
 
 ;;; Code:
 
 `url-retrieve-synchronously'."
   (goto-char 1)
   (kill-paragraph 1) ; The headers are 1 paragraph.  I hope.
-  (kill-line)        ; A line separates the headers from the file's content.
-  )
-
-;; Download any missing dependencies.
-(let ((files '("https://raw.githubusercontent.com/mooz/js2-mode/master/js2-mode.el"
-               "https://raw.githubusercontent.com/rejeep/ert-async.el/master/ert-async.el")))
-  (make-directory (download-dependencies-resolve-path "../libraries") t)
-  (dolist (file files)
-    (let* ((basename (file-name-nondirectory file))
-           (destination (download-dependencies-resolve-path
-                         (concat "../libraries/" basename))))
-      (when (null (file-exists-p destination))
-        (with-current-buffer (url-retrieve-synchronously file)
-          (download-dependencies-strip-headers)
-          (write-file destination))))))
+  (kill-line))       ; A line separates the headers from the file's content.
+
+(defun download-dependencies-get-dependencies ()
+  "Read the `dependencies' file as a list of URLs."
+  (with-temp-buffer
+    (insert-file-contents (download-dependencies-resolve-path "./dependencies"))
+    (split-string (buffer-substring-no-properties (point-min) (point-max)))))
+
+(defun download-dependencies ()
+  "Download dependencies for development."
+  (let ((files (download-dependencies-get-dependencies)))
+    (make-directory (download-dependencies-resolve-path "../libraries") t)
+    (dolist (file files)
+      (let* ((basename (file-name-nondirectory file))
+             (destination (download-dependencies-resolve-path
+                           (concat "../libraries/" basename))))
+        (unless (file-exists-p destination)
+          (with-current-buffer (url-retrieve-synchronously file)
+            (download-dependencies-strip-headers)
+            (write-file destination)))))))
 
 ;;; download-dependencies.el ends here