worktree-flow 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +0,0 @@
1
- import path from 'node:path';
2
- /**
3
- * Use case for running post-checkout commands.
4
- * Runs commands either directly in worktree directories or in tmux panes.
5
- */
6
- export class RunPostCheckoutUseCase {
7
- workspaceDir;
8
- postCheckout;
9
- tmux;
10
- constructor(workspaceDir, postCheckout, tmux) {
11
- this.workspaceDir = workspaceDir;
12
- this.postCheckout = postCheckout;
13
- this.tmux = tmux;
14
- }
15
- async execute(params) {
16
- // Skip if no commands configured
17
- if (!params.postCheckout && (!params.perRepoPostCheckout || Object.keys(params.perRepoPostCheckout).length === 0)) {
18
- return undefined;
19
- }
20
- // Get worktree directories
21
- const worktreeDirs = this.workspaceDir.getWorktreeDirs(params.workspacePath);
22
- // Map each worktree to its command (per-repo overrides global)
23
- const commandsToRun = worktreeDirs
24
- .map((dir, index) => {
25
- const repoName = path.basename(dir);
26
- const command = params.perRepoPostCheckout?.[repoName] ?? params.postCheckout;
27
- return command ? { dir, command, paneIndex: index + 1 } : null;
28
- })
29
- .filter((x) => x !== null);
30
- // Run commands in parallel
31
- let successCount = 0;
32
- await Promise.allSettled(commandsToRun.map(async ({ dir, command, paneIndex }) => {
33
- try {
34
- if (params.tmuxEnabled && params.sessionName) {
35
- // Panes are indexed from 0, first pane (root) is 0, worktrees start at 1
36
- await this.tmux.sendKeysToPane(params.sessionName, paneIndex, command);
37
- }
38
- else {
39
- await this.postCheckout.runCommandInDirectory(dir, command);
40
- }
41
- successCount++;
42
- }
43
- catch {
44
- // Error handled by counting successes
45
- }
46
- }));
47
- return { successCount, totalCount: commandsToRun.length };
48
- }
49
- }