JSPM

command-exists-promise

2.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 124271
  • Score
    100M100P100Q161606F
  • License MIT

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

Package Exports

  • command-exists-promise

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (command-exists-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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
}