-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrom-path.ts
More file actions
26 lines (23 loc) · 967 Bytes
/
Copy pathfrom-path.ts
File metadata and controls
26 lines (23 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @file `bazelFromPath()` — looks for `bazelisk` first, then `bazel`, on the
* system PATH. Bazelisk is preferred because it honors `.bazelversion` and
* downloads the project-pinned Bazel into its own cache — closer to what real
* Bazel users want. Returns `undefined` if neither is found on PATH.
*/
import { which } from '../../bin/which'
import type { ResolvedBazel } from './types'
export async function bazelFromPath(): Promise<ResolvedBazel | undefined> {
const bazelisk = await which('bazelisk', { nothrow: true })
/* c8 ignore start - reached only when bazelisk is on PATH. */
if (typeof bazelisk === 'string') {
return { path: bazelisk, source: 'path' }
}
/* c8 ignore stop */
const bazel = await which('bazel', { nothrow: true })
/* c8 ignore start - reached only when bazel is on PATH. */
if (typeof bazel === 'string') {
return { path: bazel, source: 'path' }
}
/* c8 ignore stop */
return undefined
}