nose-pluto/app/nose/bin/update.ts
Chris Wanstrath 487aa4ce7e who knows
2025-09-29 18:34:21 -07:00

22 lines
551 B
TypeScript

// Update NOSE itself and restart.
import { $ } from "bun"
export default async function () {
if (process.env.NODE_ENV !== "production") {
return { error: "Can only update in production." }
}
const { stdout } = await $`cd .. && git pull`.quiet()
const out = stdout.toString()
if (/up to date/.test(out)) {
return "Up to date."
} else {
setTimeout(() => process.exit(), 1000)
return {
text: "Reloading in 3 seconds...",
script: `setTimeout(() => (window as any).location = window.location, 3000)`
}
}
}