Merge pull request #2000 from CyrilTaylor/dev/portable/userData_location

set userData location to the 'data' folder which at the same level as the Terminus executable directory if exist with portable mode
This commit is contained in:
Eugene 2020-01-14 09:26:26 +01:00 committed by GitHub
commit 472b421484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,8 @@ import { app, ipcMain, Menu } from 'electron'
import { parseArgs } from './cli'
import { Application } from './app'
import electronDebug = require('electron-debug')
import * as path from 'path'
import * as fs from 'fs'
if (!process.env.TERMINUS_PLUGINS) {
process.env.TERMINUS_PLUGINS = ''
@ -11,6 +13,17 @@ if (!process.env.TERMINUS_PLUGINS) {
const application = new Application()
const portableData = path.join(`${process.env.PORTABLE_EXECUTABLE_DIR}`, 'data')
if (('PORTABLE_EXECUTABLE_DIR' in process.env) && fs.existsSync(portableData)) {
fs.stat(portableData, (err, stats) => {
if (stats.isDirectory()) {
app.setPath('userData' ,portableData)
} else {
console.warn(err)
}
})
}
ipcMain.on('app:new-window', () => {
application.newWindow()
})