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 d2e84d8
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 (publisher name)
(let ((latest
(with-temp-buffer
(url-insert-file-contents
(format
"https://api.github.com/repos/%s/%s/releases/latest"
publisher name))
(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 d2e84d8

Please sign in to comment.