Function
isWsl
(
platform: NodeJS.Platform,
osRelease: string,
procVersionFilePath: string,
)
Source from the content-addressed store, hash-verified
| 370 | * @returns {Boolean} boolean if it is WSL |
| 371 | */ |
| 372 | export const isWsl = async ( |
| 373 | platform: NodeJS.Platform, |
| 374 | osRelease: string, |
| 375 | procVersionFilePath: string, |
| 376 | ): Promise<boolean> => { |
| 377 | if (platform !== "linux") { |
| 378 | return false |
| 379 | } |
| 380 | |
| 381 | if (osRelease.toLowerCase().includes("microsoft")) { |
| 382 | return true |
| 383 | } |
| 384 | |
| 385 | try { |
| 386 | return (await fs.readFile(procVersionFilePath, "utf8")).toLowerCase().includes("microsoft") |
| 387 | } catch (_) { |
| 388 | return false |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | interface OpenOptions { |
| 393 | args: string[] |
Tested by
no test coverage detected