Doctor's comment-checker probe only checked system PATH and the package binary while the runtime resolution path checks the lazy-download cache first. Aligned the doctor resolution order with runtime so the cached binary is recognized as installed. 🤖 Generated with OhMyOpenCode assistance https://github.com/code-yeongyu/oh-my-opencode
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect } from "bun:test"
|
||||
import { describe, it, expect, mock } from "bun:test"
|
||||
import * as deps from "./dependencies"
|
||||
|
||||
describe("dependencies check", () => {
|
||||
@@ -41,5 +41,25 @@ describe("dependencies check", () => {
|
||||
expect(info.required).toBe(false)
|
||||
expect(typeof info.installed).toBe("boolean")
|
||||
})
|
||||
|
||||
it("returns installed=true when cached binary exists", async () => {
|
||||
//#given cached binary exists
|
||||
const mockCachedPath = "/mock/path/to/comment-checker"
|
||||
|
||||
mock.module("../../../hooks/comment-checker/downloader", () => ({
|
||||
getCachedBinaryPath: () => mockCachedPath,
|
||||
getCacheDir: () => "/mock/cache/dir",
|
||||
getBinaryName: () => "comment-checker",
|
||||
downloadCommentChecker: async () => mockCachedPath,
|
||||
ensureCommentCheckerBinary: async () => mockCachedPath,
|
||||
}))
|
||||
|
||||
//#when checking
|
||||
const info = await deps.checkCommentChecker()
|
||||
|
||||
//#then reports installed=true with cached path
|
||||
expect(info.installed).toBe(true)
|
||||
expect(info.path).toBe(mockCachedPath)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path"
|
||||
|
||||
import type { DependencyInfo } from "../types"
|
||||
import { spawnWithTimeout } from "../spawn-with-timeout"
|
||||
import { getCachedBinaryPath } from "../../../hooks/comment-checker/downloader"
|
||||
|
||||
async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> {
|
||||
try {
|
||||
@@ -113,6 +114,19 @@ function findCommentCheckerPackageBinary(): string | null {
|
||||
}
|
||||
|
||||
export async function checkCommentChecker(): Promise<DependencyInfo> {
|
||||
// Check cached binary first (matches runtime resolution order)
|
||||
const cachedPath = getCachedBinaryPath()
|
||||
if (cachedPath) {
|
||||
const version = await getBinaryVersion(cachedPath)
|
||||
return {
|
||||
name: "Comment Checker",
|
||||
required: false,
|
||||
installed: true,
|
||||
version,
|
||||
path: cachedPath,
|
||||
}
|
||||
}
|
||||
|
||||
const binaryCheck = await checkBinaryExists("comment-checker")
|
||||
const resolvedPath = binaryCheck.exists ? binaryCheck.path : findCommentCheckerPackageBinary()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user