-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed template path lookup. #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Changed template path resolution to only use the application installation directory - Added fallback to default template when template file doesn't exist - Added debug logging for template resolution - Improved error messaging
WalkthroughThe changes update the Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
index.js (3)
112-122
: Fix trailing space on line 116The function looks good with improved template lookup, proper error handling, and helpful logging. However, there's a trailing space on line 116 that should be removed.
// Get template ONLY from the script's installation directory const scriptDir = getScriptDir(); - const templatePath = path.join(scriptDir, 'templates', 'PULL_REQUEST_TEMPLATE.twig'); + const templatePath = path.join(scriptDir, 'templates', 'PULL_REQUEST_TEMPLATE.twig'); // Check if template exists in the app installation directory🧰 Tools
🪛 GitHub Check: test (22.x)
[warning] 116-116:
Trailing spaces not allowed
210-230
: Fix trailing space on line 212The template rendering logic has been properly updated to handle both default and file-based templates. Remove the trailing space on line 212.
// Get template and render it const template = getTemplatePath(); - + let renderedTemplate;🧰 Tools
🪛 GitHub Check: test (22.x)
[warning] 212-212:
Trailing spaces not allowed
119-121
: Consider consistent log formattingThe warning message style is inconsistent with other logs in the codebase. Consider standardizing the log format.
- console.log(`🔍 Template not found in application directory: ${templatePath}`); - console.log('⚠️ Using default template'); + console.log(`\n🔍 Template not found in application directory: ${templatePath}`); + console.log('\n⚠️ Using default template');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.gitignore
(1 hunks)index.js
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: test (22.x)
index.js
[warning] 116-116:
Trailing spaces not allowed
[warning] 212-212:
Trailing spaces not allowed
🔇 Additional comments (3)
.gitignore (1)
1-2
: Good addition to ignore local configuration filesThe gitignore pattern properly excludes all
settings.local.json
files within any.claude
directory at any depth in the repository. This is a good practice to keep local configuration files out of version control.index.js (2)
83-101
: Good fallback template implementationAdding a default template as a fallback makes the tool more robust and ensures it will work even if the template file is missing.
103-109
: Consider Windows path compatibility issueThe current implementation might have an issue on Windows systems.
URL(fileUrl).pathname
will include a leading slash on Windows, which could cause path resolution problems.Consider handling Windows paths explicitly:
function getScriptDir() { // Use import.meta.url to get the full URL of the current module const fileUrl = import.meta.url; // Convert the file URL to a system path and get the directory - return path.dirname(new URL(fileUrl).pathname); + const pathname = new URL(fileUrl).pathname; + // Handle Windows paths that start with a leading slash after URL conversion + const normalizedPath = process.platform === 'win32' ? pathname.substring(1) : pathname; + return path.dirname(normalizedPath); }
Checklist before requesting a review
Changed
Screenshots
Summary by CodeRabbit
Refactor
Chores
.gitignore
to exclude allsettings.local.json
files within any.claude
directory.