diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index bb663c5e3..85b92b4da 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -45,6 +45,7 @@ const CSS_FILES = [ `${appPath}/node_modules/codemirror/lib/codemirror.css`, `${appPath}/node_modules/react-image-carousel/lib/css/main.min.css` ] +const win = global.process.platform === 'win32' function buildStyle ( fontFamily, @@ -673,11 +674,9 @@ export default class MarkdownPreview extends React.Component { GetCodeThemeLink (name) { const theme = consts.THEMES.find(theme => theme.name === name) - if (theme) { - return `${appPath}/${theme.path}` - } else { - return `${appPath}/node_modules/codemirror/theme/elegant.css` - } + return theme + ? (win ? theme.path : `${appPath}/${theme.path}`) + : `${appPath}/node_modules/codemirror/theme/elegant.css` } rewriteIframe () { diff --git a/browser/lib/consts.js b/browser/lib/consts.js index 9c9930551..3603c202a 100644 --- a/browser/lib/consts.js +++ b/browser/lib/consts.js @@ -7,6 +7,7 @@ const CODEMIRROR_THEME_PATH = 'node_modules/codemirror/theme' const CODEMIRROR_EXTRA_THEME_PATH = 'extra_scripts/codemirror/theme' const isProduction = process.env.NODE_ENV === 'production' + const paths = [ isProduction ? path.join(app.getAppPath(), CODEMIRROR_THEME_PATH) : path.resolve(CODEMIRROR_THEME_PATH), isProduction ? path.join(app.getAppPath(), CODEMIRROR_EXTRA_THEME_PATH) : path.resolve(CODEMIRROR_EXTRA_THEME_PATH) diff --git a/browser/main/DevTools/index.js b/browser/main/DevTools/index.js index 93d666a24..d39d5fbbe 100644 --- a/browser/main/DevTools/index.js +++ b/browser/main/DevTools/index.js @@ -1,8 +1,8 @@ /* eslint-disable no-undef */ -if (process.env.NODE_ENV === 'production') { +if (process.env.NODE_ENV === 'development') { // eslint-disable-next-line global-require - module.exports = require('./index.prod').default + module.exports = require('./index.dev').default } else { // eslint-disable-next-line global-require - module.exports = require('./index.dev').default + module.exports = require('./index.prod').default } diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index bea019fa9..78ea93883 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -108,7 +108,6 @@ function validate (config) { } function _save (config) { - console.log(config) window.localStorage.setItem('config', JSON.stringify(config)) } @@ -141,7 +140,7 @@ function get () { const theme = consts.THEMES.find(theme => theme.name === config.editor.theme) if (theme) { - editorTheme.setAttribute('href', `../${theme.path}`) + editorTheme.setAttribute('href', win ? theme.path : `../${theme.path}`) } else { config.editor.theme = 'default' } @@ -183,7 +182,7 @@ function set (updates) { const newTheme = consts.THEMES.find(theme => theme.name === newConfig.editor.theme) if (newTheme) { - editorTheme.setAttribute('href', `../${newTheme.path}`) + editorTheme.setAttribute('href', win ? newTheme.path : `../${newTheme.path}`) } ipcRenderer.send('config-renew', { diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index f74dbda52..91a257721 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -14,6 +14,7 @@ import { getLanguages } from 'browser/lib/Languages' import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' const OSX = global.process.platform === 'darwin' +const win = global.process.platform === 'win32' const electron = require('electron') const ipc = electron.ipcRenderer @@ -135,7 +136,7 @@ class UiTab extends React.Component { const theme = consts.THEMES.find(theme => theme.name === newCodemirrorTheme) if (theme) { - checkHighLight.setAttribute('href', `../${theme.path}`) + checkHighLight.setAttribute('href', win ? theme.path : `../${theme.path}`) } } diff --git a/browser/main/store.js b/browser/main/store.js index c708c3ad8..d48198a79 100644 --- a/browser/main/store.js +++ b/browser/main/store.js @@ -476,7 +476,8 @@ const reducer = combineReducers({ router: connectRouter(history) }) -const store = createStore(reducer, undefined, compose( - applyMiddleware(routerMiddleware(history)), DevTools.instrument())) +const store = createStore(reducer, undefined, process.env.NODE_ENV === 'development' + ? compose(applyMiddleware(routerMiddleware(history)), DevTools.instrument()) + : applyMiddleware(routerMiddleware(history))) export { store, history } diff --git a/lib/main-window.js b/lib/main-window.js index e650cb922..515dc8b45 100644 --- a/lib/main-window.js +++ b/lib/main-window.js @@ -54,7 +54,7 @@ const mainWindow = new BrowserWindow({ }, icon: path.resolve(__dirname, '../resources/app.png') }) -const url = path.resolve(__dirname, process.env.NODE_ENV === 'production' ? './main.production.html' : './main.development.html') +const url = path.resolve(__dirname, process.env.NODE_ENV === 'development' ? './main.development.html' : './main.production.html') mainWindow.loadURL('file://' + url) mainWindow.setMenuBarVisibility(false) diff --git a/tests/dataApi/copyFile-test.js b/tests/dataApi/copyFile-test.js index 412d510a0..533b13543 100644 --- a/tests/dataApi/copyFile-test.js +++ b/tests/dataApi/copyFile-test.js @@ -3,6 +3,9 @@ const copyFile = require('browser/main/lib/dataApi/copyFile') const path = require('path') const fs = require('fs') +const os = require('os') +const execSync = require('child_process').execSync +const removeDirCommand = os.platform() === 'win32' ? 'rmdir /s /q ' : 'rm -rf ' const testFile = 'test.txt' const srcFolder = path.join(__dirname, '🤔') @@ -29,7 +32,7 @@ test('`copyFile` should handle encoded URI on src path', (t) => { test.after((t) => { fs.unlinkSync(srcPath) fs.unlinkSync(dstPath) - fs.rmdirSync(srcFolder) - fs.rmdirSync(dstFolder) + execSync(removeDirCommand + '"' + srcFolder + '"') + execSync(removeDirCommand + '"' + dstFolder + '"') })