This repository has been archived on 2024-01-16. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Maneger/commandExist.js

22 lines
597 B
JavaScript
Raw Normal View History

2021-04-29 11:36:27 -03:00
const { readdirSync, existsSync } = require("fs");
const { resolve } = require("path");
function getBins() {
const PATHs = process.env.PATH.split(/;?:/g);
const bin = []
for (let path of PATHs){
2021-04-29 13:18:19 -03:00
if (path.includes("\\")) path = path.replaceAll("\\", "/")
2021-04-29 11:36:27 -03:00
if (existsSync(path))
for (let binS of readdirSync(resolve(path))) bin.push(binS)
}
return bin
}
function commdExist(command){
let bin = getBins()
for (let index of bin) if (index === command) return true
return false
}
module.exports = commdExist
module.exports.sync = commdExist