fix(windows): resolve paths[0] TypeError crash on Windows startup (#351)

- Fix comment-checker/downloader.ts to use Windows-appropriate cache paths (%LOCALAPPDATA% or %APPDATA%) instead of Unix-style ~/.cache
- Guard against undefined import.meta.url in cli.ts which can occur during Windows plugin loading
- Reorder cache check before module resolution for safer fallback behavior

Fixes #347

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
Sisyphus
2025-12-30 22:14:04 +09:00
committed by GitHub
parent 7a2ffac5b7
commit f210194e30
2 changed files with 23 additions and 9 deletions
+15 -8
View File
@@ -23,6 +23,19 @@ function getBinaryName(): string {
function findCommentCheckerPathSync(): string | null {
const binaryName = getBinaryName()
// Check cached binary first (safest path - no module resolution needed)
const cachedPath = getCachedBinaryPath()
if (cachedPath) {
debugLog("found binary in cache:", cachedPath)
return cachedPath
}
// Guard against undefined import.meta.url (can happen on Windows during plugin loading)
if (!import.meta.url) {
debugLog("import.meta.url is undefined, skipping package resolution")
return null
}
try {
const require = createRequire(import.meta.url)
const cliPkgPath = require.resolve("@code-yeongyu/comment-checker/package.json")
@@ -33,14 +46,8 @@ function findCommentCheckerPathSync(): string | null {
debugLog("found binary in main package:", binaryPath)
return binaryPath
}
} catch {
debugLog("main package not installed")
}
const cachedPath = getCachedBinaryPath()
if (cachedPath) {
debugLog("found binary in cache:", cachedPath)
return cachedPath
} catch (err) {
debugLog("main package not installed or resolution failed:", err)
}
debugLog("no binary found in known locations")