1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

application data directory

This commit is contained in:
Kyle Spearrin
2018-05-14 08:26:00 -04:00
parent 70c7b182ae
commit ad2fa7efbb
2 changed files with 13 additions and 6 deletions

View File

@@ -4,10 +4,19 @@ import { Utils } from 'jslib/misc/utils';
let localStorage = Utils.isBrowser ? window.localStorage : null;
export class NodeStorageService implements StorageService {
constructor(dirLocation: string) {
constructor(appDirName: string) {
if (Utils.isNode && localStorage == null) {
const LocalStorage = require('node-localstorage').LocalStorage;
localStorage = new LocalStorage(dirLocation);
let path = null;
if (process.platform === 'darwin') {
path = process.env.HOME + 'Library/Application Support';
} else if (process.platform === 'win32') {
path = process.env.APPDATA;
} else {
path = process.env.HOME + '.config';
}
path += ('/' + appDirName + '/data');
localStorage = new LocalStorage(path);
}
}