improve(plugin): compatible for non-semver release package

pull/3871/head
charlie 2022-01-10 15:29:43 +08:00 committed by Andelf
parent b7c62d98c8
commit 24ad679d7c
1 changed files with 7 additions and 4 deletions

View File

@ -121,7 +121,8 @@
(defn install-or-update!
[{:keys [version repo only-check] :as item}]
(when repo
(let [updating? (and version (. semver valid version))]
(let [coerced-version (and version (. semver coerce version))
updating? (and version (. semver valid coerced-version))]
(debug (if updating? "Updating:" "Installing:") repo)
@ -134,12 +135,13 @@
_ (debug "[Release Asset] #" latest-version " =>" (:url asset))
;; compare latest version
_ (when (and updating? latest-version
(. semver valid latest-version))
_ (when-let [coerced-latest-version
(and updating? latest-version
(. semver coerce latest-version))]
(debug "[Updating Latest?] " version " > " latest-version)
(if (. semver lt version latest-version)
(if (. semver lt coerced-version coerced-latest-version)
(debug "[Updating Latest] " latest-version)
(throw (js/Error. :no-new-version))))
@ -147,6 +149,7 @@
(:browser_download_url asset) asset)
_ (when-not dl-url
(debug "[Download URL Error]" asset)
(throw (js/Error. :release-asset-not-found)))
dest (.join path cfgs/dot-root "plugins" (:id item))