From 196d01aae2d7bbbb78a50ce20d7388371176fed8 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Sat, 5 Jun 2021 22:11:47 -0400 Subject: [PATCH] fix: Fix cli path on windows to launch connect shell --- ui/desktop/electron-app/src/cli/index.js | 11 ++--------- ui/desktop/electron-app/src/cli/path.js | 11 +++++++++++ ui/desktop/electron-app/src/helpers/spawn-promise.js | 10 +++++----- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 ui/desktop/electron-app/src/cli/path.js diff --git a/ui/desktop/electron-app/src/cli/index.js b/ui/desktop/electron-app/src/cli/index.js index 99092ffe3..9af290e0e 100644 --- a/ui/desktop/electron-app/src/cli/index.js +++ b/ui/desktop/electron-app/src/cli/index.js @@ -1,16 +1,9 @@ -const path = require('path'); -const { isWindows } = require('../helpers/platform.js'); const { spawnSync } = require('../helpers/spawn-promise.js'); - -const cliPath = async () => { - let name = 'boundary'; - if (isWindows()) name = 'boundary.exe'; - return path.resolve(__dirname, '..', 'cli', name); -}; +const { path } = require('./path.js'); module.exports = { // Check boundary cli existence - exists: () => Boolean(cliPath()), + exists: () => Boolean(path()), // Returns JSON-formatted version information from the CLI version: () => { diff --git a/ui/desktop/electron-app/src/cli/path.js b/ui/desktop/electron-app/src/cli/path.js new file mode 100644 index 000000000..4e452b0f0 --- /dev/null +++ b/ui/desktop/electron-app/src/cli/path.js @@ -0,0 +1,11 @@ +const path = require('path'); +const { isWindows } = require('../helpers/platform.js'); + +module.exports = { + // Returns boundary cli path + path: () => { + let name = 'boundary'; + if (isWindows()) name = 'boundary.exe'; + return path.resolve(__dirname, '..', '..', 'cli', name); + } +}; diff --git a/ui/desktop/electron-app/src/helpers/spawn-promise.js b/ui/desktop/electron-app/src/helpers/spawn-promise.js index b8ff5d980..af2da4ab3 100644 --- a/ui/desktop/electron-app/src/helpers/spawn-promise.js +++ b/ui/desktop/electron-app/src/helpers/spawn-promise.js @@ -1,8 +1,7 @@ -const path = require('path'); +const { path } = require('../cli/path.js'); const { spawn, spawnSync } = require('child_process'); const jsonify = require('../utils/jsonify.js'); - -const boundaryPath = path.resolve(__dirname, '..', '..', 'cli', 'boundary'); +const { isWindows } = require('../helpers/platform.js'); // You can throw exceptions, or allow them to occur, and this is supported. // Exceptions thrown in this way will be returned to the UI as an @@ -29,7 +28,7 @@ module.exports = { */ spawnAsyncJSONPromise(command) { return new Promise((resolve, reject) => { - const childProcess = spawn(boundaryPath, command); + const childProcess = spawn(path(), command, { shell: isWindows() }); let outputStream = ''; let errorStream = ''; @@ -56,6 +55,7 @@ module.exports = { }; childProcess.stderr.on('error', processError); + childProcess.stderr.on('data', processError); }); }, @@ -66,7 +66,7 @@ module.exports = { * @return {string} */ spawnSync(command) { - const childProcess = spawnSync(boundaryPath, command); + const childProcess = spawnSync(path(), command, { shell: isWindows() }); const rawOutput = childProcess.output.toString(); return rawOutput; },