MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / detectWsl

Function detectWsl

src/sync/watch-policy.ts:30–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28 * `/proc/version`, which contains "microsoft" on WSL kernels.
29 */
30export function detectWsl(): boolean {
31 if (wslChecked) return wslValue;
32 wslChecked = true;
33
34 if (process.platform !== 'linux') {
35 wslValue = false;
36 return wslValue;
37 }
38 if (process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP) {
39 wslValue = true;
40 return wslValue;
41 }
42 try {
43 const version = fs.readFileSync('/proc/version', 'utf8').toLowerCase();
44 wslValue = version.includes('microsoft') || version.includes('wsl');
45 } catch {
46 wslValue = false;
47 }
48 return wslValue;
49}
50
51/**
52 * True for WSL Windows-drive mounts like `/mnt/c` or `/mnt/d/project`.

Callers 1

watchDisabledReasonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected