setup-cpp/src/check-updates.ts

17 lines
536 B
TypeScript
Raw Normal View History

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