Commit fe61437
committed
fix(update): prevent updateRemoveDir from deleting non-wrapper directories
The ?? fallback after wrapperSpec() returned undefined was reading
dependencies from an arbitrary parent directory's package.json,
which could match and return that directory as the removal target.
For example, when the plugin sits inside .config/opencode/node_modules/,
updateRemoveDir would return .config/opencode as the dir to rm -rf,
because .config/opencode/package.json lists the DCP dependency.
Remove the fallback entirely. wrapperSpec() is the sole authority:
if the wrapper directory doesn't match the expected opencode naming
convention (@scope/pkg@spec), return undefined.
Add a regression test that reproduces the .config/opencode-like
directory structure and asserts undefined is returned.1 parent 2cc6b88 commit fe61437
2 files changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
| 90 | + | |
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
| |||
0 commit comments