@seasonkoh/webaz 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Database from 'better-sqlite3';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
const
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
const DATA_DIR = path.join(os.homedir(), '.webaz');
|
|
10
|
+
if (!fs.existsSync(DATA_DIR))
|
|
11
|
+
fs.mkdirSync(DATA_DIR, { recursive: true });
|
|
12
|
+
const DB_PATH = path.join(DATA_DIR, 'webaz.db');
|
|
10
13
|
export function initDatabase() {
|
|
11
14
|
const db = new Database(DB_PATH);
|
|
12
15
|
db.pragma('journal_mode = WAL'); // 更好的并发性能
|
package/package.json
CHANGED