-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ElectronAppAdapter.ts
46 lines (35 loc) · 1.01 KB
/
ElectronAppAdapter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as path from "path"
import { AppAdapter, getAppCacheDir } from "./AppAdapter"
export class ElectronAppAdapter implements AppAdapter {
constructor(private readonly app = require("electron").app) {}
whenReady(): Promise<void> {
return this.app.whenReady()
}
get version(): string {
return this.app.getVersion()
}
get name(): string {
return this.app.getName()
}
get isPackaged(): boolean {
return this.app.isPackaged === true
}
get appUpdateConfigPath(): string {
return this.isPackaged ? path.join(process.resourcesPath, "app-update.yml") : path.join(this.app.getAppPath(), "dev-app-update.yml")
}
get userDataPath(): string {
return this.app.getPath("userData")
}
get baseCachePath(): string {
return getAppCacheDir()
}
quit(): void {
this.app.quit()
}
relaunch(): void {
this.app.relaunch()
}
onQuit(handler: (exitCode: number) => void): void {
this.app.once("quit", (_: Electron.Event, exitCode: number) => handler(exitCode))
}
}