mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-14 16:37:27 +00:00
Merge pull request #438 from jjavierdguezas/fix/get-environment-info
fix package.json path resolution on development
This commit is contained in:
commit
24e766f337
3 changed files with 8 additions and 11 deletions
|
@ -2,16 +2,19 @@ import {app} from 'electron';
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import isRenderer from 'is-electron-renderer';
|
||||
|
||||
const getPackageJson = () => {
|
||||
let appPath;
|
||||
if (process.env.NODE_ENV === 'production') appPath = app.getAppPath();
|
||||
else if (isRenderer) appPath = path.join(__dirname, '..');
|
||||
else appPath = path.join(__dirname, '..', '..');
|
||||
else appPath = process.cwd();
|
||||
|
||||
const pkgContent = fs.readFileSync(path.join(appPath, 'package.json'));
|
||||
return JSON.parse(pkgContent);
|
||||
const pkgPath = path.join(appPath, 'package.json');
|
||||
if (fs.existsSync(pkgPath)) {
|
||||
const pkgContent = fs.readFileSync(pkgPath);
|
||||
return JSON.parse(pkgContent);
|
||||
}
|
||||
console.error(`cant find package.json in: '${appPath}'`);
|
||||
return {};
|
||||
};
|
||||
|
||||
export const pkg = getPackageJson();
|
||||
|
|
|
@ -296,7 +296,6 @@
|
|||
"flwww": "^2.0.10",
|
||||
"framer-motion": "^2.2.0",
|
||||
"history": "^4.7.2",
|
||||
"is-electron-renderer": "^2.0.1",
|
||||
"jimp": "^0.12.1",
|
||||
"lodash": "^4.17.19",
|
||||
"merge-img": "^2.1.3",
|
||||
|
|
|
@ -9181,11 +9181,6 @@ is-docker@^2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.0.0.tgz#2cb0df0e75e2d064fe1864c37cdeacb7b2dcf25b"
|
||||
integrity sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==
|
||||
|
||||
is-electron-renderer@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-electron-renderer/-/is-electron-renderer-2.0.1.tgz#a469d056f975697c58c98c6023eb0aa79af895a2"
|
||||
integrity sha1-pGnQVvl1aXxYyYxgI+sKp5r4laI=
|
||||
|
||||
is-es2016-keyword@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-es2016-keyword/-/is-es2016-keyword-1.0.0.tgz#f6e54e110c5e4f8d265e69d2ed0eaf8cf5f47718"
|
||||
|
|
Loading…
Reference in a new issue