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
Plugins and themes can be installed directly from the Settings view inside Terminus. 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 path from 'path'
import * as fs from 'fs' import * as fs from 'fs'
if (process.env.PORTABLE_EXECUTABLE_DIR) { let appPath: string | null = null
const portableData = path.join(process.env.PORTABLE_EXECUTABLE_DIR, 'terminus-data') try {
if (!fs.existsSync(portableData)) { appPath = path.dirname(require('electron').app.getPath('exe'))
fs.mkdirSync(portableData) } catch {
} appPath = path.dirname(require('electron').remote.app.getPath('exe'))
}
try { if (null != appPath) {
require('electron').app.setPath('userData', portableData) if(fs.existsSync(path.join(appPath, 'terminus-data'))) {
} catch { fs.renameSync(path.join(appPath, 'terminus-data'), path.join(appPath, 'data'))
require('electron').remote.app.setPath('userData', portableData) }
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: win:
icon: "./build/windows/icon.ico" 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 rfc3161TimeStampServer: http://sha256timestamp.ws.symantec.com/sha256/timestamp
nsis: nsis:
oneClick: false oneClick: false
artifactName: terminus-${version}-setup.${ext} artifactName: terminus-${version}-setup.${ext}
installerIcon: "./build/windows/icon.ico" installerIcon: "./build/windows/icon.ico"
portable:
artifactName: terminus-${version}-portable.exe
mac: mac:
category: public.app-category.video category: public.app-category.video

View File

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