1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

replace electron store with lowdb

This commit is contained in:
Kyle Spearrin
2018-05-31 09:07:56 -04:00
parent 98e2e611f8
commit f618c0b5ee
7 changed files with 121 additions and 42 deletions

16
src/misc/nodeUtils.ts Normal file
View File

@@ -0,0 +1,16 @@
import * as fs from 'fs';
import * as path from 'path';
export class NodeUtils {
static mkdirpSync(targetDir: string, mode = 755, relative = false, relativeDir: string = null) {
const initialDir = path.isAbsolute(targetDir) ? path.sep : '';
const baseDir = relative ? (relativeDir != null ? relativeDir : __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);
}
}

View File

@@ -13,9 +13,9 @@ export class Utils {
}
Utils.inited = true;
Utils.isNode = typeof window === 'undefined';
Utils.isBrowser = !Utils.isNode;
Utils.global = Utils.isNode ? global : window;
Utils.isNode = typeof process !== 'undefined' && (process as any).release.name === 'node';
Utils.isBrowser = typeof window !== 'undefined';
Utils.global = Utils.isNode && !Utils.isBrowser ? global : window;
}
static fromB64ToArray(str: string): Uint8Array {