* v4.12.2...v5.12.0 * chore: 🤖 yarn.lock file changes * chore: 🤖 ember init blueprint updates * chore: 🤖 yarn.lock changes * style: 💄 run linter and formatter * chore: 🤖 yarn.lock file changes * chore: 🤖 remove ember-cli-app-version ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16547
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
const path = require('path');
|
|
const { isWindows } = require('../helpers/platform.js');
|
|
const isDev = require('electron-is-dev');
|
|
const { existsSync } = require('node:fs');
|
|
const which = require('which');
|
|
|
|
const binaryName = isWindows() ? 'boundary.exe' : 'boundary';
|
|
const builtInCliPath = isDev
|
|
? path.resolve(__dirname, '..', '..', 'cli', binaryName)
|
|
: path.resolve(process.resourcesPath, 'cli', binaryName);
|
|
|
|
// 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
|
|
: // On Windows, we need to filter out the path that is within the current working directory.
|
|
// This is necessary because the spawn methods may not always find the correct binary path.
|
|
// The `which` module returns an array of all available paths for the 'boundary' binary.
|
|
// We then filter out the path that is within the current working directory.
|
|
isWindows()
|
|
? which
|
|
.sync(binaryName, { nothrow: true, all: true })
|
|
.filter((binary) => !binary.startsWith(process.cwd()))[0]
|
|
: binaryName;
|
|
|
|
module.exports = {
|
|
path: pathBoundary,
|
|
isBuiltInCli,
|
|
};
|