feat: implement prepareSqlitePath function and add tests for database path handling
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
|
||||
export function prepareSqlitePath(databaseUrl: string): string {
|
||||
const sqlitePath = databaseUrl.replace(/^file:/, "");
|
||||
|
||||
if (sqlitePath !== ":memory:") {
|
||||
mkdirSync(dirname(sqlitePath), { recursive: true });
|
||||
}
|
||||
|
||||
return sqlitePath;
|
||||
}
|
||||
Reference in New Issue
Block a user