Skip to content

Node module to check if a command-line command exists.

License

Notifications You must be signed in to change notification settings

raftario/command-exists

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Node module to check if a command-line command exists.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%