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:
16
src/misc/nodeUtils.ts
Normal file
16
src/misc/nodeUtils.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user