2023-04-22 12:14:22 +08:00
|
|
|
import { warning } from "ci-log"
|
2023-05-24 12:26:47 +08:00
|
|
|
import { promises } from "fs"
|
|
|
|
const { readFile } = promises
|
2023-04-22 12:14:22 +08:00
|
|
|
import { join } from "path"
|
|
|
|
|
|
|
|
// auto self update notifier
|
|
|
|
export async function checkUpdates() {
|
|
|
|
try {
|
2023-04-22 12:31:40 +08:00
|
|
|
const { UpdateNotifier } = await import("update-notifier")
|
2023-04-22 12:14:22 +08:00
|
|
|
const packageJsonString = await readFile(join(__dirname, "..", "package.json"), "utf8")
|
|
|
|
const packageJson = JSON.parse(packageJsonString)
|
2023-04-22 12:31:40 +08:00
|
|
|
new UpdateNotifier({ pkg: packageJson }).notify()
|
2023-04-22 12:14:22 +08:00
|
|
|
} catch (err) {
|
|
|
|
warning(`Failed to check for updates: ${err}`)
|
|
|
|
}
|
|
|
|
}
|