1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-23 13:13:49 +03:00

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:
Cyril Taylor 2020-01-14 15:06:54 +08:00
parent b61bc943ec
commit 8201e0b9ef

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()
})