Skip to content

Commit

Permalink
utils: A helper to get the latest release from github
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jan 6, 2023
1 parent dbe0177 commit c1f3f7e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dap-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,25 @@ PATH is the download destination dir."
(f-join dap-utils-extension-path "openvsx" (concat publisher "." name)))))
(dap-utils--get-extension url dest)))

(defun dap-utils-get-github-extension (owner repo version &optional path)
(defun dap-utils-get-github-extension (owner repo &optional version path)
"Get extension from github named OWNER/REPO with VERSION.
PATH is the download destination path."
(let* ((url (format dap-utils-github-extension-url owner repo version))
(let* ((version (or version (dap-utils-get-github-extension-latest-version owner repo)))
(url (format dap-utils-github-extension-url owner repo version))
(dest (or path
(f-join dap-utils-extension-path "github" (concat owner "." repo)))))
(dap-utils--get-extension url dest)))

(defun dap-utils-get-github-extension-latest-version (owner repo)
(let ((latest
(with-temp-buffer
(url-insert-file-contents
(format
"https://api.github.com/repos/%s/%s/releases/latest"
owner repo))
(json-parse-buffer :object-type 'plist))))
(car (last (split-string (plist-get latest :html_url) "/")))))

(defun dap-utils-vscode-get-installed-extension-version (path)
"Check the version of the vscode extension installed in PATH.
Returns nil if the extension is not installed."
Expand Down

0 comments on commit c1f3f7e

Please sign in to comment.