linux-command-exists
TypeScript icon, indicating that this package has built-in type declarations

0.0.6-1 • Public • Published

linux-command-exists

Check if a command exists

Examples

var commandExists = require("linux-command-exists").commandExists;
 
//With Promise
commandExists("ls")
  .then(exists => {
    if (exists === true) {
      console.log("The command ls exists");
    } else {
      console.log('The command "ls" doesn\'t exists');
    }
  })
  .catch(e => {
    console.error(`An error happened:\n${e.message}`);
  });
 
//With Callback
commandExists("ls", (error, exists) => {
  if (error) {
    console.error(`An error happened:\n${e.message}`);
  } else {
    if (exists === true) {
      console.log('The command "ls" exists');
    } else {
      console.log('The command "ls" doesn\'t exists');
    }
  }
});

Package Sidebar

Install

npm i linux-command-exists

Weekly Downloads

23

Version

0.0.6-1

License

GPL-3.0

Unpacked Size

48.2 kB

Total Files

8

Last publish

Collaborators

  • alpi