mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
create app dir if not exists
This commit is contained in:
@@ -64,18 +64,18 @@ export class Program {
|
||||
program.on('--help', () => {
|
||||
writeLn('\n Examples:');
|
||||
writeLn('');
|
||||
writeLn(' $ bw login');
|
||||
writeLn(' $ bw sync');
|
||||
writeLn(' $ bw lock');
|
||||
writeLn(' $ bw unlock myPassword321');
|
||||
writeLn(' $ bw generate -lusn --length 18');
|
||||
writeLn(' $ bw list items --search google');
|
||||
writeLn(' $ bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412');
|
||||
writeLn(' $ bw get password google.com');
|
||||
writeLn(' $ bw delete item 99ee88d2-6046-4ea7-92c2-acac464b1412');
|
||||
writeLn(' $ echo \'{"name":"My Folder"}\' | bw encode');
|
||||
writeLn(' $ bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K');
|
||||
writeLn(' $ bw edit folder c7c7b60b-9c61-40f2-8ccd-36c49595ed72 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==');
|
||||
writeLn(' bw login');
|
||||
writeLn(' bw sync');
|
||||
writeLn(' bw lock');
|
||||
writeLn(' bw unlock myPassword321');
|
||||
writeLn(' bw generate -lusn --length 18');
|
||||
writeLn(' bw list items --search google');
|
||||
writeLn(' bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412');
|
||||
writeLn(' bw get password google.com');
|
||||
writeLn(' bw delete item 99ee88d2-6046-4ea7-92c2-acac464b1412');
|
||||
writeLn(' echo \'{"name":"My Folder"}\' | bw encode');
|
||||
writeLn(' bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K');
|
||||
writeLn(' bw edit folder c7c7b60b-9c61-40f2-8ccd-36c49595ed72 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==');
|
||||
writeLn('');
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ export class Program {
|
||||
.action(async (email: string, password: string, cmd: program.Command) => {
|
||||
await this.exitIfAuthed();
|
||||
const command = new LoginCommand(this.main.authService, this.main.apiService,
|
||||
this.main.cryptoFunctionService);
|
||||
this.main.cryptoFunctionService, this.main.syncService);
|
||||
const response = await command.run(email, password, cmd);
|
||||
this.processResponse(response);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import * as fs from 'fs';
|
||||
import * as lowdb from 'lowdb';
|
||||
import * as FileSync from 'lowdb/adapters/FileSync';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as path from 'path';
|
||||
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
@@ -8,17 +11,20 @@ export class LowdbStorageService implements StorageService {
|
||||
private db: lowdb.LowdbSync<any>;
|
||||
|
||||
constructor(appDirName: string) {
|
||||
let path = null;
|
||||
let p = null;
|
||||
if (process.platform === 'darwin') {
|
||||
path = process.env.HOME + '/Library/Application Support';
|
||||
p = path.join(process.env.HOME, 'Library/Application Support', appDirName);
|
||||
} else if (process.platform === 'win32') {
|
||||
path = process.env.APPDATA;
|
||||
p = path.join(process.env.APPDATA, appDirName);
|
||||
} else {
|
||||
path = process.env.HOME + '/.config';
|
||||
p = path.join(process.env.HOME, '.config', appDirName);
|
||||
}
|
||||
path += ('/' + appDirName + '/data.json');
|
||||
if (!fs.existsSync(p)) {
|
||||
mkdirp.sync(p, 755);
|
||||
}
|
||||
p = path.join(p, 'data.json');
|
||||
|
||||
const adapter = new FileSync(path);
|
||||
const adapter = new FileSync(p);
|
||||
this.db = lowdb(adapter);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user