( parsed: ParsedPowerShellCommand, name: string, )
| 1543 | * Handles common aliases too. |
| 1544 | */ |
| 1545 | export function hasCommandNamed( |
| 1546 | parsed: ParsedPowerShellCommand, |
| 1547 | name: string, |
| 1548 | ): boolean { |
| 1549 | const lowerName = name.toLowerCase() |
| 1550 | const canonicalFromAlias = COMMON_ALIASES[lowerName]?.toLowerCase() |
| 1551 | |
| 1552 | for (const cmdName of getAllCommandNames(parsed)) { |
| 1553 | if (cmdName === lowerName) { |
| 1554 | return true |
| 1555 | } |
| 1556 | // Check if the command is an alias that resolves to the requested name |
| 1557 | const canonical = COMMON_ALIASES[cmdName]?.toLowerCase() |
| 1558 | if (canonical === lowerName) { |
| 1559 | return true |
| 1560 | } |
| 1561 | // Check if the requested name is an alias and the command is its canonical form |
| 1562 | if (canonicalFromAlias && cmdName === canonicalFromAlias) { |
| 1563 | return true |
| 1564 | } |
| 1565 | // Check if both resolve to the same canonical cmdlet (alias-to-alias match) |
| 1566 | if (canonical && canonicalFromAlias && canonical === canonicalFromAlias) { |
| 1567 | return true |
| 1568 | } |
| 1569 | } |
| 1570 | return false |
| 1571 | } |
| 1572 | |
| 1573 | /** |
| 1574 | * Check if the command contains any directory-changing commands. |
no test coverage detected