       (buffer-string))))
 
 (defun skewer-bower-git-clone (url package)
-  "Clone or update a package's repository if needed."
+  "Clone or fetch PACKAGE's repository from URL if needed."
   (if (member package skewer-bower-refreshed)
       t
     (let* ((cache (skewer-bower-cache package))

(defun skewer-bower-package-versions (package)
  "List the available versions for a package."
  (skewer-bower-package-ensure package)
  (sort (skewer-bower-git-tag package) #'string<))

(defun skewer-bower-get-config (package &optional version)
  "Get the configuration for a package."
  (skewer-bower-package-ensure package)
  (json-read-from-string
   (skewer-bower-git-show package (or version "master") "bower.json")))

;; Serving the library

(defun skewer-bower-load (package &optional version)
  "Dynamically load a library from bower into the page."
  (interactive
   (let* ((packages (mapcar #'car skewer-bower-packages))
          (package (completing-read "Library: " packages nil t))
          (versions (skewer-bower-package-versions package))
          (version (completing-read "Version: " (reverse versions) nil t)))
     (list package version)))
  (let* ((config (skewer-bower-get-config package))
         (main (cdr (assoc 'main config))))
    (skewer-eval (concat "/skewer/bower/" package "/" (or version "master")
                         "/" main) nil
                 :type "script")))

(defservlet skewer/bower application/javascript (path)
  "Serve a file from the local repository cache."

          (insert contents)
        (httpd-error t 404)))))

(provide 'skewer-bower)

;;; skewer-bower.el ends here
