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/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 new file mode 100644 index 00000000..fdfc3795 --- /dev/null +++ b/lib/is.js @@ -0,0 +1,10 @@ +const electron = require('electron'); +const app = electron.app || electron.remote.app; + +module.exports = { + main: process.type === 'browser', + renderer: process.type === 'renderer', + prod: app.isPackaged, + // ugh, this probably shouldn't be here + userData: app.getPath('userData') +}; 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 }) => {