From 14bfbc2d5ccac351d8af82a3a42c44b7b3014898 Mon Sep 17 00:00:00 2001 From: SimonFJ20 Date: Thu, 26 Sep 2024 01:35:13 +0200 Subject: [PATCH] auto make db --- main.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.ts b/main.ts index 9317322..36232fe 100644 --- a/main.ts +++ b/main.ts @@ -22,6 +22,22 @@ interface Db { createSession(init: Omit): Promise; } +try { + await Deno.lstat("bunker.db"); +} catch (error) { + if (!(error instanceof Deno.errors.NotFound)) { + throw error; + } + const cmd = new Deno.Command("sqlite3", { + args: ["bunker.db", ".read database.sql"], + stdout: "piped", + stderr: "piped", + }); + console.log( + await cmd.output().then((out) => new TextDecoder().decode(out.stdout)), + ); +} + class SqliteDb implements Db { private db = new sqlite.Database("bunker.db", { create: false });