MCPcopy Create free account
hub / github.com/wonderwhy-er/DesktopCommanderMCP / isShellAvailable

Function isShellAvailable

test/test-default-shell.js:34–66  ·  view source on GitHub ↗

* Check if a shell is available on the system

(shellPath)

Source from the content-addressed store, hash-verified

32 * Check if a shell is available on the system
33 */
34async function isShellAvailable(shellPath) {
35 try {
36 // For Windows shells, use different detection methods
37 if (shellPath === 'cmd' || shellPath === 'cmd.exe') {
38 // On Windows, cmd should always be available
39 if (os.platform() === 'win32') {
40 return true;
41 }
42 return false;
43 }
44
45 if (shellPath === 'pwsh' || shellPath === 'powershell') {
46 // Check if PowerShell is available
47 try {
48 const result = await executeCommand(`${shellPath} -Command "Get-Host"`, 2000);
49 return result.content && result.content[0] && !result.content[0].text.includes('not found');
50 } catch (error) {
51 return false;
52 }
53 }
54
55 // For Unix shells, check if the file exists and is executable
56 try {
57 const result = await executeCommand(`test -x "${shellPath}" && echo "available"`, 2000);
58 return result.content && result.content[0] && result.content[0].text.includes('available');
59 } catch (error) {
60 return false;
61 }
62 } catch (error) {
63 console.log(`Could not check availability of ${shellPath}: ${error.message}`);
64 return false;
65 }
66}
67
68/**
69 * Get expected shell output for a given shell path

Callers 6

testDefaultShellShFunction · 0.85
testDefaultShellBashFunction · 0.85
testDefaultShellCmdFunction · 0.85
testDefaultShellPwshFunction · 0.85
testShellSwitchingFunction · 0.85

Calls 2

logMethod · 0.80
executeCommandFunction · 0.70

Tested by

no test coverage detected