Check if a binary exists in your system PATH.
- Fully compatible with TypeScript.
- Supports both ESM (ES Modules) and CommonJS module systems.
Replace and execute the command according to the package manager you are using. Here is an example of npm.
npm install --save-dev has-command
import { hasCommand } from 'has-command';
console.log(await hasCommand('cd')); // true
console.log(await hasCommand('nonexistent_command')); // false
const { hasCommand } = require('has-command');
console.log(await hasCommand('cd')); // true
console.log(await hasCommand('nonexistent_command')); // false