MCPcopy Create free account
hub / github.com/anus-dev/ANUS / isCommandAvailable

Method isCommandAvailable

packages/core/src/tools/grep.ts:212–228  ·  view source on GitHub ↗

* Checks if a command is available in the system's PATH. * @param {string} command The command name (e.g., 'git', 'grep'). * @returns {Promise } True if the command is available, false otherwise.

(command: string)

Source from the content-addressed store, hash-verified

210 * @returns {Promise<boolean>} True if the command is available, false otherwise.
211 */
212 private isCommandAvailable(command: string): Promise<boolean> {
213 return new Promise((resolve) => {
214 const checkCommand = process.platform === 'win32' ? 'where' : 'command';
215 const checkArgs =
216 process.platform === 'win32' ? [command] : ['-v', command];
217 try {
218 const child = spawn(checkCommand, checkArgs, {
219 stdio: 'ignore',
220 shell: process.platform === 'win32',
221 });
222 child.on('close', (code) => resolve(code === 0));
223 child.on('error', () => resolve(false));
224 } catch {
225 resolve(false);
226 }
227 });
228 }
229
230 /**
231 * Parses the standard output of grep-like commands (git grep, system grep).

Callers 1

performGrepSearchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected