Skip to content
/ which Public

Look up executable(s) in directories listed in your PATH(s)

License

Notifications You must be signed in to change notification settings

kldzj/which

Repository files navigation

which

A which (1)-like utility.

Returns the single first instance of the command executable that can be found, and null otherwise.

Usage

// async (promise)
import { which } from '@kldzj/which';

const ffmpegPath = await which('ffmpeg');

// sync (import as you prefer)
import { which, whichSync } from '@kldzj/which';

const nodePath = which.sync('node');
const samePath = whichSync('node');

Options

import { join } from 'path';
import { which } from '@kldzj/which';

const path = await which('executable', {
  // pass additional paths to search in
  paths: [join(__dirname, 'bin')],
  // pass additional extensions to search for
  exeExt: ['.xyz'],
});

About

Look up executable(s) in directories listed in your PATH(s)

Resources

License

Stars

Watchers

Forks

Packages