Use is-electron package for accurate environment identification

This commit is contained in:
Ryo Narita 2021-10-05 13:42:05 +09:00
parent 1b2088c555
commit 01f230e448
3 changed files with 3 additions and 12 deletions

1
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"ipfs-pubsub-1on1": "~0.0.6",
"is-electron": "^2.2.0",
"is-node": "^1.0.2",
"localstorage-down": "^0.6.7",
"logplease": "^1.2.14",

View File

@ -18,6 +18,7 @@
"main": "src/OrbitDB.js",
"dependencies": {
"ipfs-pubsub-1on1": "~0.0.6",
"is-electron": "^2.2.0",
"is-node": "^1.0.2",
"localstorage-down": "^0.6.7",
"logplease": "^1.2.14",

View File

@ -1,16 +1,5 @@
/* eslint-disable */
// adapted from https://github.com/cheton/is-electron - (c) Cheton Wu
const isElectron = () => {
if (typeof window !== 'undefined' && typeof window.process === 'object') {
return true
}
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
return false
}
const isElectron = require('is-electron')
const fs = (!isElectron() && (typeof window === 'object' || typeof self === 'object')) ? null : eval('require("fs")')