mirror of
https://github.com/coder/code-server.git
synced 2025-09-25 17:16:23 +08:00
Check updates daily instead of every time
Also add a way to force a check.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import * as fs from "fs-extra"
|
||||
import * as path from "path"
|
||||
import { extend, xdgLocalDir } from "./util"
|
||||
import { logger } from "@coder/logger"
|
||||
import { extend } from "./util"
|
||||
|
||||
export type Settings = { [key: string]: Settings | string | boolean | number }
|
||||
|
||||
@ -32,9 +33,28 @@ export class SettingsProvider<T> {
|
||||
*/
|
||||
public async write(settings: Partial<T>): Promise<void> {
|
||||
try {
|
||||
await fs.writeFile(this.settingsPath, JSON.stringify(extend(this.read(), settings)))
|
||||
await fs.writeFile(this.settingsPath, JSON.stringify(extend(await this.read(), settings), null, 2))
|
||||
} catch (error) {
|
||||
logger.warn(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global code-server settings.
|
||||
*/
|
||||
export interface CoderSettings {
|
||||
lastVisited: {
|
||||
url: string
|
||||
workspace: boolean
|
||||
}
|
||||
update: {
|
||||
checked: number
|
||||
version: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global code-server settings file.
|
||||
*/
|
||||
export const settings = new SettingsProvider<CoderSettings>(path.join(xdgLocalDir, "coder.json"))
|
||||
|
Reference in New Issue
Block a user