You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

command-exists

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-exists

check whether a command line command exists in the current environment

1.2.9
latest
Source
npmnpm
Version published
Weekly downloads
3.3M
-7.21%
Maintainers
1
Weekly downloads
 
Created

What is command-exists?

The command-exists npm package is used to check if a given command is available in the system's PATH. It is useful for Node.js applications that need to ensure certain commands are installed before attempting to execute them.

What are command-exists's main functionalities?

Synchronous check

This feature allows you to synchronously check if a command exists in the system's PATH.

const commandExistsSync = require('command-exists').sync;

if (commandExistsSync('git')) {
  console.log('Git exists!');
} else {
  console.log('Git does not exist.');
}

Asynchronous check

This feature allows you to asynchronously check if a command exists in the system's PATH.

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

commandExists('git', function(err, commandExists) {
  if(commandExists) {
    console.log('Git exists!');
  } else {
    console.log('Git does not exist.');
  }
});

Promise-based check

This feature provides a promise-based interface to check if a command exists, which can be used with modern async/await syntax.

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

commandExists('git')
  .then(function(command) {
    console.log('Git exists!');
  }).catch(function() {
    console.log('Git does not exist.');
  });

Other packages similar to command-exists

Keywords

cli

FAQs

Package last updated on 15 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts