MCPcopy Create free account
hub / github.com/cortexkit/magic-context / isExecutable

Function isExecutable

packages/cli/src/lib/find-on-path.ts:55–75  ·  view source on GitHub ↗
(path: string, isWindows: boolean)

Source from the content-addressed store, hash-verified

53}
54
55function isExecutable(path: string, isWindows: boolean): boolean {
56 try {
57 if (!existsSync(path)) return false;
58 // statSync follows symlinks by default — important because wrapper
59 // scripts and tool-version shims are often symlinks. We want the
60 // target to be a regular file or directory entry that resolves
61 // to one, not a broken symlink.
62 const st = statSync(path);
63 if (!st.isFile()) return false;
64 if (isWindows) {
65 // Windows doesn't have execute permission bits the way POSIX
66 // does — the .exe/.cmd/.bat extension match is the contract.
67 return true;
68 }
69 // POSIX: check X_OK for the current user/group/other.
70 accessSync(path, constants.X_OK);
71 return true;
72 } catch {
73 return false;
74 }
75}

Callers 1

findOnPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected