fix: fix runtime path in typescript config#750
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR changes the Nuxt module override in the prepare command to resolve the module path from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/prepare.spec.ts`:
- Around line 17-19: Indentation in test/prepare.spec.ts is inconsistent around
the await exec(...) call and the nested options/object and test blocks; fix by
aligning the nested object properties and nested blocks to the project's lint
style (e.g., two-space indentation) so the await exec('pnpm',
['nuxt-module-build', 'prepare', prepareRootDir], { nodeOptions: { cwd:
workspaceDir }, }) call and surrounding test/describe/it blocks (the code
referencing exec, nodeOptions, cwd, workspaceDir) have consistent indentation
for each nested level; update lines around the exec call and the nearby lines
27–31 so nested braces and array elements line up with the same indent depth.
- Around line 9-10: The prepareRootDir calculation is using string replace on
exampleDir which can alter unrelated parts of the path; change it to derive the
temp workspace from the parent directory instead: compute the parent dir (e.g.
via path.dirname(exampleDir) or new URL('../', exampleDir) semantics) and then
build prepareRootDir by joining that parent with '.temp-example-prepare'
(referencing the existing exampleDir and prepareRootDir identifiers so you
replace the replace(...) expression with a dirname + path.join/URL-based sibling
path).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1c03822f-e5ed-490b-bda4-0904cd2bc9b9
📒 Files selected for processing (1)
test/prepare.spec.ts
| const exampleDir = fileURLToPath(new URL('../example', import.meta.url)) | ||
| const prepareRootDir = exampleDir.replace('example', '.temp-example-prepare') |
There was a problem hiding this comment.
Derive the temp workspace from the parent directory, not a string replace.
exampleDir.replace('example', '.temp-example-prepare') rewrites the first example anywhere in the absolute path. On a checkout path like /tmp/example-repos/module-builder/example, this points to /tmp/.temp-example-prepare-repos/module-builder/example, so the test copies and prepares the wrong directory. Build the sibling path from dirname(exampleDir) instead.
Proposed fix
const workspaceDir = fileURLToPath(new URL('..', import.meta.url))
const exampleDir = fileURLToPath(new URL('../example', import.meta.url))
-const prepareRootDir = exampleDir.replace('example', '.temp-example-prepare')
+const prepareRootDir = join(dirname(exampleDir), '.temp-example-prepare')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/prepare.spec.ts` around lines 9 - 10, The prepareRootDir calculation is
using string replace on exampleDir which can alter unrelated parts of the path;
change it to derive the temp workspace from the parent directory instead:
compute the parent dir (e.g. via path.dirname(exampleDir) or new URL('../',
exampleDir) semantics) and then build prepareRootDir by joining that parent with
'.temp-example-prepare' (referencing the existing exampleDir and prepareRootDir
identifiers so you replace the replace(...) expression with a dirname +
path.join/URL-based sibling path).
🔗 Linked issue
resolves #749
📚 Description
Looks like this is fixing the path in TypeScript and the build command still works. Tests are failing but they are also failing for me without the change. I added a test for that use case that runs through.
I'm not sure if we need to convert slashes when matching the path in the test since I'm usually using node:path, which uses OS-specific slashes.