improve the launch performance of portable

This commit is contained in:
Cyril Taylor 2020-02-13 01:48:18 +08:00
parent e764b22698
commit 9b7c446fd7
4 changed files with 28 additions and 13 deletions

View file

@ -35,6 +35,10 @@
---
# Portable
For portable in windows, user can create folder `data` at the same directory as `Terminal.exe` to save the settings.
# Plugins
Plugins and themes can be installed directly from the Settings view inside Terminus.

View file

@ -1,15 +1,24 @@
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)
}
let appPath: string | null = null
try {
appPath = path.dirname(require('electron').app.getPath('exe'))
} catch {
appPath = path.dirname(require('electron').remote.app.getPath('exe'))
}
try {
require('electron').app.setPath('userData', portableData)
} catch {
require('electron').remote.app.setPath('userData', portableData)
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)
}
}
}

View file

@ -14,14 +14,16 @@ publish:
win:
icon: "./build/windows/icon.ico"
artifactName: terminus-${version}-setup.exe
target: [
'nsis',
'zip'
]
artifactName: terminus-${version}.${ext}
rfc3161TimeStampServer: http://sha256timestamp.ws.symantec.com/sha256/timestamp
nsis:
oneClick: false
artifactName: terminus-${version}-setup.${ext}
installerIcon: "./build/windows/icon.ico"
portable:
artifactName: terminus-${version}-portable.exe
mac:
category: public.app-category.video

View file

@ -7,7 +7,7 @@ const isCI = !!process.env.GITHUB_REF
builder({
dir: true,
win: ['nsis', 'portable'],
win: ['nsis', 'zip'],
config: {
extraMetadata: {
version: vars.version,