Merge pull request #2081 from CyrilTaylor/dev/portable_for_plugins

Fix: save plugins to path `UserData` for fit portable mode
This commit is contained in:
Eugene 2020-02-03 16:18:29 +03:00 committed by GitHub
commit 15f99c8ae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 31 deletions

View File

@ -1,11 +1,10 @@
import './portable'
import './sentry' import './sentry'
import './lru' import './lru'
import { app, ipcMain, Menu } from 'electron' import { app, ipcMain, Menu } from 'electron'
import { parseArgs } from './cli' import { parseArgs } from './cli'
import { Application } from './app' import { Application } from './app'
import electronDebug = require('electron-debug') import electronDebug = require('electron-debug')
import * as path from 'path'
import * as fs from 'fs'
if (!process.env.TERMINUS_PLUGINS) { if (!process.env.TERMINUS_PLUGINS) {
process.env.TERMINUS_PLUGINS = '' process.env.TERMINUS_PLUGINS = ''
@ -13,14 +12,6 @@ if (!process.env.TERMINUS_PLUGINS) {
const application = new Application() const application = new Application()
if (process.env.PORTABLE_EXECUTABLE_DIR) {
const portableData = path.join(process.env.PORTABLE_EXECUTABLE_DIR, 'terminus-data')
if (!fs.existsSync(portableData)) {
fs.mkdirSync(portableData)
}
app.setPath('userData', portableData)
}
ipcMain.on('app:new-window', () => { ipcMain.on('app:new-window', () => {
application.newWindow() application.newWindow()
}) })

15
app/lib/portable.ts Executable file
View File

@ -0,0 +1,15 @@
import * as path from 'path'
import * as fs from 'fs'
if (process.env.PORTABLE_EXECUTABLE_DIR) {
const portableData = path.join(process.env.PORTABLE_EXECUTABLE_DIR, 'terminus-data')
if (!fs.existsSync(portableData)) {
fs.mkdirSync(portableData)
}
try {
require('electron').app.setPath('userData', portableData)
} catch {
require('electron').remote.app.setPath('userData', portableData)
}
}

0
app/lib/sentry.ts Normal file → Executable file
View File