()
| 587 | } |
| 588 | |
| 589 | const openMenu = async (): Promise<CommandDefinition | undefined> => { |
| 590 | ensureFzfIsInstalled() |
| 591 | |
| 592 | const recentCommands = await readRecentCommands() |
| 593 | const menuCommands = orderCommandsForMenu(getFeaturedCommands(), recentCommands) |
| 594 | const widths = getMenuColumnWidths(menuCommands) |
| 595 | const menuInput = menuCommands.map((command) => formatMenuLine(command, widths, recentCommands)).join('\n') |
| 596 | |
| 597 | const previewCommand = String.raw`printf '%s\n' {5}` |
| 598 | const result = spawnSync( |
| 599 | 'fzf', |
| 600 | [ |
| 601 | '--ansi', |
| 602 | '--delimiter', |
| 603 | '\t', |
| 604 | '--with-nth', |
| 605 | '1', |
| 606 | '--preview', |
| 607 | previewCommand, |
| 608 | '--preview-window', |
| 609 | 'down,3,wrap', |
| 610 | '--prompt', |
| 611 | 'make > ', |
| 612 | '--header', |
| 613 | 'Recent commands are pinned first. * marks commands from history.' |
| 614 | ], |
| 615 | { |
| 616 | cwd: ROOT_DIRECTORY, |
| 617 | input: menuInput, |
| 618 | encoding: 'utf8', |
| 619 | stdio: ['pipe', 'pipe', 'inherit'] |
| 620 | } |
| 621 | ) |
| 622 | |
| 623 | return getSelectedCommandFromFzfResult({ |
| 624 | status: result.status, |
| 625 | stdout: result.stdout |
| 626 | }) |
| 627 | } |
| 628 | |
| 629 | const runShellCommand = async (command: CommandDefinition): Promise<number> => { |
| 630 | await recordRecentCommand(HISTORY_PATH, command.key, Date.now()) |
no test coverage detected