Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store config file in user data directory in production #217

Merged
merged 2 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/color.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions lib/is.js
Original file line number Diff line number Diff line change
@@ -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')
};
6 changes: 1 addition & 5 deletions lib/isomorphic.js
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down