command-exists-promise
Checks whether a command line command exists in the current environment.
Last updated 7 years ago by raftario .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install command-exists-promise 
SYNC missed versions from official npm registry.

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
}

Current Tags

  • 2.0.2                                ...           latest (7 years ago)

3 Versions

  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |