fix(remote): ensure output directories exist before file writing#383
fix(remote): ensure output directories exist before file writing#383
Conversation
There was a problem hiding this comment.
PR Overview
This PR fixes an issue where file writing fails by ensuring that the necessary directories exist prior to file operations.
- In src/core/packager/writeOutputToDisk.ts, a directory creation step is added before writing files.
- In src/cli/actions/remoteAction.ts, a similar step is added before copying files.
Reviewed Changes
| File | Description |
|---|---|
| src/core/packager/writeOutputToDisk.ts | Added mkdir to create parent folder for output file before writing. |
| src/cli/actions/remoteAction.ts | Added mkdir to create target folder for copying the output file. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
📝 WalkthroughWalkthroughThe pull request updates two functions responsible for writing output files. In the CLI action function Sequence Diagram(s)sequenceDiagram
participant C as Caller
participant F as copyOutputToCurrentDirectory
participant FS as File System
C->>F: Invoke copyOutputToCurrentDirectory(source, target)
F->>FS: fs.mkdir(target, {recursive: true})
FS-->>F: Directory created (or already exists)
F->>FS: Execute file copy operation
FS-->>F: File copied successfully
F-->>C: Return success (or error if any)
sequenceDiagram
participant C as Caller
participant W as writeOutputToDisk
participant L as Logger
participant FS as File System
C->>W: Invoke writeOutputToDisk(outputPath, data)
W->>L: Log output path
W->>FS: fs.mkdir(path.dirname(outputPath), {recursive: true})
FS-->>W: Directory created (or already exists)
W->>FS: Write data to disk
FS-->>W: File written successfully
W-->>C: Return success (or error if any)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (7)
🔇 Additional comments (1)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
6963513 to
0055b36
Compare
Deploying repomix with
|
| Latest commit: |
0055b36
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0df16432.repomix.pages.dev |
| Branch Preview URL: | https://fix-create-output-directorie.repomix.pages.dev |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #383 +/- ##
=======================================
Coverage 90.17% 90.17%
=======================================
Files 72 72
Lines 3470 3472 +2
Branches 750 750
=======================================
+ Hits 3129 3131 +2
Misses 341 341 ☔ View full report in Codecov by Sentry. |
When using nested output paths (e.g.
--output docs/nested/file.xml), the tool fails because parent directories are not automatically created. This PR fixes the issue by ensuring folders exist before writing files.related: #378
Checklist
npm run testnpm run lint