mirror of
https://github.com/bitwarden/cli
synced 2026-01-05 01:33:15 +00:00
add export command
This commit is contained in:
@@ -6,6 +6,8 @@ import * as path from 'path';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
import { CliUtils } from '../utils';
|
||||
|
||||
export class LowdbStorageService implements StorageService {
|
||||
private db: lowdb.LowdbSync<any>;
|
||||
|
||||
@@ -19,7 +21,7 @@ export class LowdbStorageService implements StorageService {
|
||||
p = path.join(process.env.HOME, '.config', appDirName);
|
||||
}
|
||||
if (!fs.existsSync(p)) {
|
||||
this.mkdirpSync(p, 755);
|
||||
CliUtils.mkdirpSync(p, 755);
|
||||
}
|
||||
p = path.join(p, 'data.json');
|
||||
|
||||
@@ -41,16 +43,4 @@ export class LowdbStorageService implements StorageService {
|
||||
this.db.unset(key).write();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private mkdirpSync(targetDir: string, mode = 755, relative = false) {
|
||||
const initialDir = path.isAbsolute(targetDir) ? path.sep : '';
|
||||
const baseDir = relative ? __dirname : '.';
|
||||
targetDir.split(path.sep).reduce((parentDir, childDir) => {
|
||||
const dir = path.resolve(baseDir, parentDir, childDir);
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, mode);
|
||||
}
|
||||
return dir;
|
||||
}, initialDir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user