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 = [] } tauri-build = { version = "1.2", features = [] }
[dependencies] [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 = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"

View File

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

View File

@ -15,10 +15,13 @@ export class IPC<T extends { type: string }> {
child: Promise<Child>; child: Promise<Child>;
constructor() { 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 => { command.stdout.on('data', line => {
this.callback(JSON.parse(line)) this.callback(JSON.parse(line))
}) })
command.stderr.on('data', line => {
console.error('daemon stderr', line)
})
this.child = command.spawn() this.child = command.spawn()
} }