Conversation
Code ReviewSummaryThis is a correct and necessary fix for Windows compatibility. On Windows, absolute file paths use backslashes (e.g., ✅ What's good
🔍 Observations (not blocking)1. Import caching caveat Dynamic This is unlikely to matter in practice for a CLI tool, but it's worth being aware of. An alternative that avoids this is: import { readFile } from 'fs/promises'
const pkg = JSON.parse(
await readFile(path.join(repoDir, 'package.json'), 'utf-8')
)This also removes the need for the 2. Non-null assertion on At line 67, await this.uploadTarball(pkg, filePath, repository!, dryrun)But VerdictLGTM — the fix is correct and should be merged. The observations above are minor and apply to pre-existing code rather than this PR's changes. |
PR Review: fix(windows): convert path to file urlSummaryThe fix correctly addresses the Windows compatibility issue. Dynamic IssuesRedundant
|
|
Code Review The PR fixes a Windows compatibility issue where dynamic import() with a bare file path fails because Windows paths are not valid module specifiers. Using fs.readFile + JSON.parse is a solid cross-platform fix. Positive Changes
Issue 1 - PR title/description mismatch (minor) The PR title says 'convert path to file url' and the description references pathToFileURL, but the final code does not use pathToFileURL. The commit history shows a two-step evolution (first tried pathToFileURL, then switched to readFile). Please update the title and description. Suggested title: fix(windows): replace dynamic import with fs.readFile for package.json Issue 2 - Missing error handling for malformed package.json JSON.parse throws a SyntaxError if the file is malformed. The existing catch block only checks for ENOENT, so a malformed package.json produces a cryptic error. Consider wrapping the parse step with a clearer message like 'Failed to parse package.json -- ensure it contains valid JSON'. Issue 3 - pkg: any typing (pre-existing, non-blocking) pkg is typed as any throughout. Not introduced by this PR, but a minimal interface would improve compile-time type safety. Verdict The core fix is correct and well-motivated. Issues 1 and 2 are worth addressing but are not blockers. fs.readFile + JSON.parse is idiomatic, robust, and cross-platform compatible. Approved with suggestions. |
This pull request makes a minor update to the way the
package.jsonfile is imported in theCommandPublishclass. The change ensures the file path is properly converted to a file URL before importing, which improves compatibility and reliability.CommandPublishto usepathToFileURLwhen importingpackage.json, ensuring correct file URL formatting. [1] [2]@Keisir can you review it?