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