Skip to content

Commit

Permalink
Refactor path() from function to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
calcaide committed Oct 3, 2024
1 parent 42df325 commit 2310728
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ui/desktop/electron-app/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { path, isBuiltInCli } = require('./path.js');

module.exports = {
// Check boundary cli existence
exists: () => Boolean(path()),
exists: () => Boolean(path),

isBuiltInCli,

Expand Down
14 changes: 7 additions & 7 deletions ui/desktop/electron-app/src/cli/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const builtInCliPath = isDev
// Return true if the CLI in usage is the built in. False if relies on system CLI.
const isBuiltInCli = existsSync(builtInCliPath);

/**
* Returns Boundary CLI path if the CLI is built in or the Boundary binary name
* if not, so we assume boundary is available within user $PATH.
*/
const pathBoundary = isBuiltInCli ? builtInCliPath : binaryName;

module.exports = {
/**
* Returns Boundary CLI path if the CLI is built in or the Boundary binary name
* if not, so we assume boundary is available within user $PATH.
*/
path: () => {
return isBuiltInCli ? builtInCliPath : binaryName;
},
path: pathBoundary,
isBuiltInCli,
};
6 changes: 3 additions & 3 deletions ui/desktop/electron-app/src/helpers/spawn-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
*/
spawnAsyncJSONPromise(command, token) {
return new Promise((resolve, reject) => {
const childProcess = spawn(path(), command, {
const childProcess = spawn(path, command, {
env: {
...process.env,
BOUNDARY_TOKEN: token,
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = {
* @param {object} envVars
* @returns {{stdout: string | undefined, stderr: string | undefined}} */
spawnSync(args, envVars = {}) {
const childProcess = spawnSync(path(), args, {
const childProcess = spawnSync(path, args, {
// Some of our outputs (namely cache daemon searching) can be very large.
// This an undocumented hack to allow for an unlimited buffer size which
// could change at any time. If it does, we should just set an arbitrarily
Expand All @@ -103,7 +103,7 @@ module.exports = {
*/
spawn(command, options) {
return new Promise((resolve, reject) => {
const childProcess = spawn(path(), command, options);
const childProcess = spawn(path, command, options);
childProcess.stdout.on('data', (data) => {
resolve({ childProcess, stdout: data.toString() });
});
Expand Down

0 comments on commit 2310728

Please sign in to comment.