Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Maintainers
1
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc