feat: run daemon using deno when dev

main
imspace 2023-03-04 21:31:08 +08:00
parent 259aa852d8
commit 64e11aa389
3 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }
[dependencies]
tauri = { version = "1.2", features = ["shell-open", "shell-sidecar", "window-all"] }
tauri = { version = "1.2", features = ["shell-execute", "shell-open", "shell-sidecar", "window-all"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View File

@ -15,6 +15,7 @@
"all": false,
"shell": {
"sidecar": true,
"execute": true,
"scope": [
{
"name": "../binaries/s3si",
@ -22,6 +23,16 @@
"args": [
"--daemon"
]
},
{
"name": "deno",
"cmd": "deno",
"args": [
"run",
"-A",
"../../s3si.ts",
"--daemon"
]
}
],
"all": false,

View File

@ -15,10 +15,13 @@ export class IPC<T extends { type: string }> {
child: Promise<Child>;
constructor() {
const command = Command.sidecar('../binaries/s3si', ['--daemon']);
const command = import.meta.env.DEV ? new Command("deno", ["run", "-A", "../../s3si.ts", "--daemon"]) : Command.sidecar('../binaries/s3si', ['--daemon']);
command.stdout.on('data', line => {
this.callback(JSON.parse(line))
})
command.stderr.on('data', line => {
console.error('daemon stderr', line)
})
this.child = command.spawn()
}