From b98b60761495da45409f796225deaa3ce4c601ec Mon Sep 17 00:00:00 2001 From: ziajka Date: Mon, 4 Feb 2019 11:29:39 +0100 Subject: [PATCH] Install SolarPuTTY when available --- .gitignore | 3 +++ installed-software.js | 18 +++++++++++++++++- .../external-software-definition.service.ts | 9 ++++++--- src/environments/environment.electron.prod.ts | 2 +- src/environments/environment.electron.ts | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ad1e4d1c..a0eaa67b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,6 @@ licenses.csv # Temps .temp-var-file.ts + +# external software +/external \ No newline at end of file diff --git a/installed-software.js b/installed-software.js index d8534435..6e2da021 100644 --- a/installed-software.js +++ b/installed-software.js @@ -40,8 +40,24 @@ async function downloadFile(resource, softwarePath) { ); } +async function getSoftwareInstallationPath(software) { + if (software.installer) { + return path.join(app.getPath('temp'), software.binary); + } + else { + const externalPath = path.join(app.getAppPath(), 'external'); + const exists = fs.existsSync(externalPath); + if (!exists) { + fs.mkdirSync(externalPath); + } + return path.join(externalPath, software.binary); + } +} + + ipcMain.on('installed-software-install', async function (event, software) { - const softwarePath = path.join(app.getPath('temp'), software.binary); + const softwarePath = await getSoftwareInstallationPath(software); + const responseChannel = `installed-software-installed-${software.name}`; if (software.type == 'web') { diff --git a/src/app/services/external-software-definition.service.ts b/src/app/services/external-software-definition.service.ts index da205e8b..26fe75b3 100644 --- a/src/app/services/external-software-definition.service.ts +++ b/src/app/services/external-software-definition.service.ts @@ -30,21 +30,24 @@ export class ExternalSoftwareDefinitionService { binary: 'Wireshark.exe', sudo: true, installation_arguments: [], - installed: false + installed: false, + installer: true } ]; const solarPutty = { name: 'SolarPuTTY', locations: [ - 'SolarPuTTY.exe' + 'SolarPuTTY.exe', + 'external\\SolarPuTTY.exe' ], type: 'web', resource: '', binary: 'SolarPuTTY.exe', sudo: false, installation_arguments: ['--only-ask'], - installed: false + installed: false, + installer: false }; if(environment.solarputty_download_url) { diff --git a/src/environments/environment.electron.prod.ts b/src/environments/environment.electron.prod.ts index b1de21c8..33e05f14 100644 --- a/src/environments/environment.electron.prod.ts +++ b/src/environments/environment.electron.prod.ts @@ -1,5 +1,5 @@ export const environment = { - solarputty_download_url: "", + solarputty_download_url: '', production: true, electron: true, }; diff --git a/src/environments/environment.electron.ts b/src/environments/environment.electron.ts index bfe95058..411afa47 100644 --- a/src/environments/environment.electron.ts +++ b/src/environments/environment.electron.ts @@ -1,5 +1,5 @@ export const environment = { production: false, electron: true, - solarputty_download_url: "" + solarputty_download_url: '', };