update checker middleware
This commit is contained in:
+13
-10
@@ -10,17 +10,20 @@ type Version = {
|
||||
message: string
|
||||
}
|
||||
|
||||
export async function checkForUpdate() {
|
||||
yargs.showVersion(version =>
|
||||
axios.get<Version[]>(latestVersionURL).then(({ data }) => {
|
||||
const latestVersion = data[0].name
|
||||
export async function checkForUpdate(): Promise<void> {
|
||||
return new Promise(res => {
|
||||
yargs.showVersion(version =>
|
||||
axios
|
||||
.get<Version[]>(latestVersionURL)
|
||||
.then(({ data }) => {
|
||||
const latestVersion = data[0].name
|
||||
|
||||
if (!(latestVersion === version))
|
||||
notifyUserAboutUpdate(latestVersion)
|
||||
|
||||
return
|
||||
}),
|
||||
)
|
||||
if (!(latestVersion === version))
|
||||
notifyUserAboutUpdate(latestVersion)
|
||||
})
|
||||
.then(() => res()),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function notifyUserAboutUpdate(version: string) {
|
||||
|
||||
Reference in New Issue
Block a user