mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-30 08:10:34 +01:00
create app dir if not exists
This commit is contained in:
parent
fc63fd32c8
commit
b425b6f509
13
package-lock.json
generated
13
package-lock.json
generated
@ -34,6 +34,15 @@
|
||||
"integrity": "sha512-esk3CG25hRtHsVHm+LOjiSFYdw8be3uIY653WUwR43Bro914HSimPgPpqgajkhTJ0awK3RQfaIxP7zvbtCpcyg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mkdirp": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-0.5.2.tgz",
|
||||
"integrity": "sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "10.0.8"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.0.8.tgz",
|
||||
@ -3102,7 +3111,6 @@
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
},
|
||||
@ -3110,8 +3118,7 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -47,6 +47,7 @@
|
||||
"@types/commander": "^2.12.2",
|
||||
"@types/lowdb": "^1.0.1",
|
||||
"@types/lunr": "^2.1.5",
|
||||
"@types/mkdirp": "^0.5.2",
|
||||
"@types/node": "^10.0.8",
|
||||
"@types/node-forge": "^0.7.1",
|
||||
"@types/readline-sync": "^1.4.3",
|
||||
@ -64,6 +65,7 @@
|
||||
"chalk": "2.4.1",
|
||||
"commander": "2.15.1",
|
||||
"lowdb": "1.0.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"node-fetch": "2.1.2",
|
||||
"node-forge": "0.7.1",
|
||||
"readline-sync": "1.4.9"
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user