-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshadow.ts
More file actions
24 lines (23 loc) · 778 Bytes
/
shadow.ts
File metadata and controls
24 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @fileoverview Shadow-bin detection. A "shadow bin" is a binary
* exposed by a transitively-installed `node_modules/.bin` directory
* rather than the system installation. Callers (`findRealBin`)
* deliberately walk past these to find the real interpreter.
*/
/**
* Check if a directory path contains any shadow bin patterns.
*
* @example
* ```typescript
* isShadowBinPath('/tmp/project/node_modules/.bin') // true
* isShadowBinPath('/usr/local/bin') // false
* ```
*/
export function isShadowBinPath(dirPath: string | undefined): boolean {
if (!dirPath) {
return false
}
// Check for node_modules/.bin pattern (Unix and Windows)
const normalized = dirPath.replace(/\\/g, '/')
return normalized.includes('node_modules/.bin')
}