Skip to content

findExecutable

findExecutable(bin, options?): Promise<string | undefined>

Defined in: find-executable.ts:89

The first runnable file named bin in options.path (default process.env.PATH), as an absolute path, or undefined. Directories and files without the exec bit don’t count.

bin must be a bare name — an empty string, ., .. or anything with a path separator throws a TypeError, as does any filesystem error other than “not there” / “not permitted”.

On Windows, where there is no exec bit, bin is tried with each PATHEXT extension unless it already ends in one (see FindExecutableOptions).

string

FindExecutableOptions = {}

Promise<string | undefined>

import { findExecutableSync } from "@theholocron/fs-utils";
// a project-local binary first, then the real PATH
const tsc = findExecutableSync("tsc", { path: join(cwd, "node_modules", ".bin") }) ?? findExecutableSync("tsc");