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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user