Commit f8045cf
committed
fix(scripts): correct corrupted versions in upgrade-deps replace callback
Cursor Bugbot caught a high-severity bug introduced by the previous
single-pass refactor. The replace callback used:
(_match, prefix, oldVersion, suffix = '') => `${prefix}${newVersion}${suffix}`
`String.prototype.replace` always passes the match offset (a number) as
the next positional argument after the captures, so for the 6 patterns
with only two captures (vitest, tsdown, @oxc-node/cli, @oxc-node/core,
oxfmt, oxlint-tsgolint), `suffix` received the offset instead of
`undefined`. The `= ''` default never kicked in, and the offset got
appended to every version. Example: `tsdown: ^0.21.8` was rewritten to
`tsdown: ^9.9.90`. The earlier smoke test missed this because it used
substring `includes()`, which still matched.
Restructure each entry to use ONE capture group (just the version) plus
a literal `replacement` string. The callback signature is now
`(_match, captured)` and ignores the trailing offset/string args, so
the positional ambiguity is gone. Verified with a byte-exact equality
test on a synthetic fixture covering non-zero offsets.1 parent 05af642 commit f8045cf
1 file changed
+36
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | | - | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
103 | | - | |
| 111 | + | |
| 112 | + | |
104 | 113 | | |
105 | 114 | | |
106 | | - | |
107 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
108 | 127 | | |
109 | 128 | | |
110 | | - | |
| 129 | + | |
| 130 | + | |
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
121 | 140 | | |
122 | | - | |
| 141 | + | |
123 | 142 | | |
124 | 143 | | |
125 | 144 | | |
126 | 145 | | |
127 | 146 | | |
| 147 | + | |
128 | 148 | | |
129 | 149 | | |
130 | 150 | | |
| |||
0 commit comments