Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

command-exists-promise

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-exists-promise

Checks whether a command line command exists in the current environment.

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

command-exists-promise

npm Travis (.com) AppVeyor
Node module to check if a command-line command exists. Forked from command-exists.

Installation

# For npm users
$ npm i command-exists-promise

# For yarn users
$ yarn add command-exists-promise

Usage

The function returns a promise that will resolve to true if the command exists and false if it doesn't.
On UNIX, the promise will resolve to true if the command is a path to an executable file. On Windows, it will resolve to true for any existing file.

Promise

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

commandExists('ls')
  .then(exists => {
    if (exists) {
      // The command exists
    } else {
      // The command doesn't exist
    }
  })
  .catch(err => {
    // Should never happen but better handle it just in case
  })

Await

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

try {
  const exists = await commandExists('ls')
  if (exists) {
    // The command exists
  } else {
    // The command doesn't exist
  }
} catch (err) {
  // Should never happen but better handle it just in case
}

Keywords

FAQs

Package last updated on 09 May 2019

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