Commit aaa78e7
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>
</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>
</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
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments