2020-02-03 12:59:46 +00:00
|
|
|
import * as path from 'path'
|
|
|
|
import * as fs from 'fs'
|
|
|
|
|
2020-02-12 17:48:18 +00:00
|
|
|
let appPath: string | null = null
|
|
|
|
try {
|
|
|
|
appPath = path.dirname(require('electron').app.getPath('exe'))
|
|
|
|
} catch {
|
|
|
|
appPath = path.dirname(require('electron').remote.app.getPath('exe'))
|
|
|
|
}
|
2020-02-03 12:59:46 +00:00
|
|
|
|
2020-02-12 17:48:18 +00:00
|
|
|
if (null != appPath) {
|
|
|
|
if(fs.existsSync(path.join(appPath, 'terminus-data'))) {
|
|
|
|
fs.renameSync(path.join(appPath, 'terminus-data'), path.join(appPath, 'data'))
|
|
|
|
}
|
|
|
|
const portableData = path.join(appPath, 'data')
|
|
|
|
if (fs.existsSync(portableData)) {
|
|
|
|
console.log('reset user data to ' + portableData)
|
|
|
|
try {
|
|
|
|
require('electron').app.setPath('userData', portableData)
|
|
|
|
} catch {
|
|
|
|
require('electron').remote.app.setPath('userData', portableData)
|
|
|
|
}
|
2020-02-03 12:59:46 +00:00
|
|
|
}
|
|
|
|
}
|