From 538eaeee50b69ff3cc9474cb50594ffcf93d90cc Mon Sep 17 00:00:00 2001 From: Kiril Vatev Date: Mon, 17 Jun 2019 18:39:31 -0400 Subject: [PATCH 1/2] separating is helper into a separate file --- lib/color.js | 5 +---- lib/is.js | 8 ++++++++ lib/isomorphic.js | 6 +----- 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 lib/is.js diff --git a/lib/color.js b/lib/color.js index a12e44f4..3b14c0ce 100644 --- a/lib/color.js +++ b/lib/color.js @@ -1,9 +1,6 @@ let chalk; -const is = { - main: process.type === 'browser', - renderer: process.type === 'renderer' -}; +const is = require('./is.js'); try { chalk = require('chalk'); diff --git a/lib/is.js b/lib/is.js new file mode 100644 index 00000000..6fc7ae8c --- /dev/null +++ b/lib/is.js @@ -0,0 +1,8 @@ +const electron = require('electron'); +const app = electron.app || electron.remote.app; + +module.exports = { + main: process.type === 'browser', + renderer: process.type === 'renderer', + prod: app.isPackaged +}; diff --git a/lib/isomorphic.js b/lib/isomorphic.js index 20cf23d4..99e1c1d4 100644 --- a/lib/isomorphic.js +++ b/lib/isomorphic.js @@ -1,11 +1,7 @@ const electron = require('electron'); +const is = require('./is.js'); const log = require('./log.js'); -const is = { - main: process.type === 'browser', - renderer: process.type === 'renderer' -}; - const gid = () => Math.random().toString(36).substr(2); module.exports = ({ name, implementation }) => { From f0b49e6bbe4b6afd0af6cd68da790768639900a3 Mon Sep 17 00:00:00 2001 From: Kiril Vatev Date: Mon, 17 Jun 2019 18:53:35 -0400 Subject: [PATCH 2/2] when running in production, config will be written to user data directory --- lib/config.js | 3 ++- lib/is.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/config.js b/lib/config.js index d99303fe..7402be8b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,12 +2,13 @@ const path = require('path'); const fs = require('fs-extra'); const _ = require('lodash'); +const is = require('./is.js'); const root = require('./root.js'); const name = 'config'; const { info, error } = require('./log.js')(name); const isomorphic = require('./isomorphic.js'); -const location = process.env['RAW_VIEWER_CONFIG_PATH'] || path.resolve(root, '.raw-viewer-config.json'); +const location = process.env['RAW_VIEWER_CONFIG_PATH'] || path.resolve(is.prod ? is.userData : root, '.raw-viewer-config.json'); let operation; let configObj = { diff --git a/lib/is.js b/lib/is.js index 6fc7ae8c..fdfc3795 100644 --- a/lib/is.js +++ b/lib/is.js @@ -4,5 +4,7 @@ const app = electron.app || electron.remote.app; module.exports = { main: process.type === 'browser', renderer: process.type === 'renderer', - prod: app.isPackaged + prod: app.isPackaged, + // ugh, this probably shouldn't be here + userData: app.getPath('userData') };