Skip to content

The cross-platform and super-fast library which can check if a command or even the commands bundle exist.

License

Notifications You must be signed in to change notification settings

pan93412/cmdexist

Repository files navigation

cmdexist

The cross-platform and super-fast library which can check if a command or even the commands bundle exist.

It should be compatible with Node v10+.

Usage

npm i cmdexist
yarn add cmdexist # or if you use yarn
/* SINGLE FILE TO TEST */
function singleFileToTest() {
  CheckIfExist("node").then((exec) => console.log(`node is ${exec}`));
}

/* MULTIPLE FILES TO TEST */
async function multipleFilesToTest() {
  // Set as `const` so TypeScript will correctly show the entries in toCheck array.
  const toCheck = ["npm", "node", "yarn", "python", "docker"] as const;
  const [result, details] = await CheckIfAllExist(toCheck);

  details; // We can see that it shows the every entries in `toCheck`.
  console.log(result);
  console.log(details);
}

For more information, See the docs and examples/ folder.

Benchmarks

See benchmarks/command-exists.ts.

commandExists - when the exe exists: 12.467ms
commandExists - when the exe not exists: 6.156ms
[our] cmdexist - when the exe exists: 0.92ms
[our] cmdexist - when the exe not exists: 0.301ms

Authors

About

The cross-platform and super-fast library which can check if a command or even the commands bundle exist.

Resources

License

Stars

Watchers

Forks

Packages

No packages published