diff --git a/README.md b/README.md index dbfaf9aa..e2d84f8a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app/lib/portable.ts b/app/lib/portable.ts index 31de6942..ed10cfc6 100755 --- a/app/lib/portable.ts +++ b/app/lib/portable.ts @@ -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) + } } } diff --git a/electron-builder.yml b/electron-builder.yml index ebbc2e94..847f72c9 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -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 diff --git a/scripts/build-windows.js b/scripts/build-windows.js index 50065cd7..998bfd9d 100755 --- a/scripts/build-windows.js +++ b/scripts/build-windows.js @@ -7,7 +7,7 @@ const isCI = !!process.env.GITHUB_REF builder({ dir: true, - win: ['nsis', 'portable'], + win: ['nsis', 'zip'], config: { extraMetadata: { version: vars.version,