Refactor Study Desk application structure
This commit is contained in:
parent
faaccf8a7e
commit
089439ed90
145 changed files with 8087 additions and 3412 deletions
10
scripts/databasePath.mjs
Normal file
10
scripts/databasePath.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import path from "node:path";
|
||||
|
||||
export function databasePathFromUrl(databaseUrl, cwd = process.cwd()) {
|
||||
if (!databaseUrl?.startsWith("file:")) {
|
||||
throw new Error("DATABASE_URL must be a file: SQLite URL");
|
||||
}
|
||||
const rawPath = databaseUrl.slice("file:".length).split("?")[0];
|
||||
if (!rawPath) throw new Error("DATABASE_URL does not contain a database path");
|
||||
return path.resolve(cwd, rawPath);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue