1. command-exists
check whether a command line command exists in the current environment
command-exists
Package: command-exists
Created by: mathisonian
Last modified: Mon, 13 Jun 2022 06:34:45 GMT
Version: 1.2.9
License: MIT
Downloads: 11,403,258
Repository: https://github.com/mathisonian/command-exists

Install

npm install command-exists
yarn add command-exists

command-exists

node module to check if a command-line command exists

installation

 npm install command-exists

usage

async

 var commandExists = require('command-exists');

commandExists('ls', function(err, commandExists) {

    if(commandExists) {
        // proceed confidently knowing this command is available
    }

});

promise

 var commandExists = require('command-exists');

// invoked without a callback, it returns a promise
commandExists('ls')
.then(function(command){
    // proceed
}).catch(function(){
    // command doesn't exist
});

sync

 var commandExistsSync = require('command-exists').sync;
// returns true/false; doesn't throw
if (commandExistsSync('ls')) {
    // proceed
} else {
    // ...
}

changelog

v1.2.7

Removes unnecessary printed output on windows.

v1.2.6

Small bugfixes.

v1.2.5

Fix windows bug introduced in 1.2.4.

v1.2.4

Fix potential security issue.

v1.2.0

Add support for promises

v1.1.0

Add synchronous version

v1.0.2

Support for windows

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code