• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apowers313 / designloom / 20964842756

13 Jan 2026 04:42PM UTC coverage: 86.527%. First build
20964842756

push

github

apowers313
feat: initial commit

520 of 616 branches covered (84.42%)

Branch coverage included in aggregate %.

2826 of 3251 new or added lines in 15 files covered. (86.93%)

2826 of 3251 relevant lines covered (86.93%)

22.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.83
/src/path-resolver.ts
1
import { execSync } from "node:child_process";
1✔
2
import * as path from "node:path";
1✔
3

4
/**
5
 * Execute a git command and return the trimmed output.
6
 * @param command - Git command arguments
7
 * @returns Output string or null on error
8
 */
9
function execGitCommand(command: string): string | null {
23✔
10
    try {
23✔
11
        const result = execSync(command, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
23✔
12
        return result.trim();
23✔
13
    } catch {
23✔
14
        return null;
6✔
15
    }
6✔
16
}
23✔
17

18
/**
19
 * Check if the current directory is in a git worktree (not the main repo).
20
 * @returns True if in a worktree, false otherwise
21
 */
22
export function isInWorktree(): boolean {
1✔
23
    const gitDir = execGitCommand("git rev-parse --git-dir");
10✔
24
    const gitCommonDir = execGitCommand("git rev-parse --git-common-dir");
10✔
25

26
    if (gitDir === null || gitCommonDir === null) {
10✔
27
        return false;
3✔
28
    }
3✔
29

30
    // If git-dir differs from git-common-dir, we're in a worktree
31
    return gitDir !== gitCommonDir;
7✔
32
}
7✔
33

34
/**
35
 * Get the path to the main repository when in a worktree.
36
 * @returns Path to main repo, or null if not in a worktree or not a git repo
37
 */
38
export function getMainRepoPath(): string | null {
1✔
39
    if (!isInWorktree()) {
7✔
40
        return null;
4✔
41
    }
4✔
42

43
    const gitCommonDir = execGitCommand("git rev-parse --git-common-dir");
3✔
44
    if (gitCommonDir === null) {
7!
NEW
45
        return null;
×
NEW
46
    }
✔
47

48
    // The common dir is typically /path/to/repo/.git
49
    // We need to return /path/to/repo
50
    return path.dirname(gitCommonDir);
3✔
51
}
3✔
52

53
/**
54
 * Resolve a data path, taking into account git worktrees.
55
 * When in a worktree, relative paths are resolved to the main repository.
56
 * Absolute paths are returned as-is.
57
 * @param configuredPath - The configured path (absolute or relative)
58
 * @returns Resolved absolute path
59
 */
60
export function resolveDataPath(configuredPath: string): string {
1✔
61
    // If it's already an absolute path, return as-is
62
    if (path.isAbsolute(configuredPath)) {
5✔
63
        return configuredPath;
1✔
64
    }
1✔
65

66
    // Check if we're in a worktree
67
    const mainRepoPath = getMainRepoPath();
4✔
68

69
    if (mainRepoPath !== null) {
5✔
70
        // We're in a worktree - resolve relative to main repo
71
        // Remove leading ./ if present
72
        const normalizedPath = configuredPath.startsWith("./")
2✔
73
            ? configuredPath.slice(2)
1✔
74
            : configuredPath;
1✔
75
        return path.join(mainRepoPath, normalizedPath);
2✔
76
    }
2✔
77

78
    // Not in a worktree (or not a git repo) - resolve relative to cwd
79
    return path.resolve(process.cwd(), configuredPath);
2✔
80
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc