Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 41809fe

Browse files
committed
fix store dir miss error
1 parent d0aa901 commit 41809fe

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/utils/store/db.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44
};
55
Object.defineProperty(exports, "__esModule", { value: true });
66
const os_1 = __importDefault(require("os"));
7+
const fs_extra_1 = __importDefault(require("fs-extra"));
78
const lowdb_1 = __importDefault(require("lowdb"));
89
const path_1 = __importDefault(require("path"));
910
const FileSync_1 = __importDefault(require("lowdb/adapters/FileSync"));
1011
const xdg_basedir_1 = __importDefault(require("xdg-basedir"));
1112
const configDir = xdg_basedir_1.default.config || path_1.default.join(os_1.default.tmpdir(), '.config');
1213
const cloudbaseConfigDir = path_1.default.join(configDir, '.cloudbase');
14+
fs_extra_1.default.ensureDirSync(cloudbaseConfigDir);
1315
function getAuthDB() {
1416
const dbPath = path_1.default.join(cloudbaseConfigDir, 'auth.json');
1517
const adapter = new FileSync_1.default(dbPath);

src/utils/store/db.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os from 'os'
2+
import fse from 'fs-extra'
23
import low from 'lowdb'
34
import path from 'path'
45
import FileSync from 'lowdb/adapters/FileSync'
@@ -9,6 +10,9 @@ const configDir = xdgBasedir.config || path.join(os.tmpdir(), '.config')
910
// cloudbase 配置目录
1011
const cloudbaseConfigDir = path.join(configDir, '.cloudbase')
1112

13+
// 确保目录存在
14+
fse.ensureDirSync(cloudbaseConfigDir)
15+
1216
export function getAuthDB() {
1317
const dbPath = path.join(cloudbaseConfigDir, 'auth.json')
1418
const adapter = new FileSync(dbPath)

0 commit comments

Comments
 (0)