Skip to content

Commit aaa78e7

Browse files
damassit1mmen
andauthored
fix: Correct template path resolution (#25)
### **User description** Taking the lib for a spin, I noticed that it wasn't resolving the paths to my preexisting templates via the `register` command. It would come out like: ``` supabase/migrations-templates/Users/cn/Sites/cn/my-project/supabase/migrations-templates/checkout.sql ``` And looking at the input paths this seemed indeed an issue: ``` path.join(baseDir, config.templateDir, templatePath) ``` so `process.cwd()` would append the dir and then the path. Looking closer, by the time templatePath is input, its already been resolved here: https://github.com/t1mmen/srtd/blob/main/src/lib/templateManager.ts#L82 So this simplifies things and fixes the issue, allowing me to register my templates. ___ ### **PR Type** Bug fix ___ ### **Description** - Fixed incorrect template path resolution in `registerTemplate`. - Removed redundant configuration-based path resolution logic. - Simplified path resolution to use `path.resolve`. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>registerTemplate.ts</strong><dd><code>Simplify and fix template path resolution logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> src/utils/registerTemplate.ts <li>Removed redundant <code>getConfig</code> import and usage.<br> <li> Simplified path resolution logic by removing unnecessary paths.<br> <li> Updated to use <code>path.resolve</code> for template path resolution. </details> </td> <td><a href="https://github.com/t1mmen/srtd/pull/25/files#diff-0374114956b919afd5f2d282074e0576c66f5780fb29b7349c3141ff74af262a">+1/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information Co-authored-by: Timm Stokke <[email protected]>
1 parent 77248cb commit aaa78e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

.changeset/thin-clocks-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@t1mmen/srtd": patch
3+
---
4+
5+
fix `register` template path resolution

0 commit comments

Comments
 (0)