| 1438 | * Find PowerShell executable from PATH (for Windows only). |
| 1439 | */ |
| 1440 | export function findPowerShell(): string | undefined { |
| 1441 | const dirs: string[] = (process.env.PATH || '').replace(/"+/g, '').split(';').filter(x => x); |
| 1442 | const exts: string[] = (process.env.PATHEXT || '').split(';'); |
| 1443 | const names: string[] = ['pwsh', 'powershell']; |
| 1444 | for (const name of names) { |
| 1445 | const candidates: string[] = dirs.reduce<string[]>((paths, dir) => [ |
| 1446 | ...paths, ...exts.map(ext => path.join(dir, name + ext)) |
| 1447 | ], []); |
| 1448 | for (const candidate of candidates) { |
| 1449 | try { |
| 1450 | if (fs.statSync(candidate).isFile()) { |
| 1451 | return name; |
| 1452 | } |
| 1453 | } catch { |
| 1454 | // ignore, try next candidate |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | export function getCppToolsTargetPopulation(): TargetPopulation { |
| 1461 | // If insiders.flag is present, consider this an insiders build. |