@@ -32,11 +32,11 @@ describe('processStrReplace', () => {
3232 const oldStr = 'const y = 2;'
3333 const newStr = 'const y = 3;'
3434
35- const result = await processStrReplace (
36- 'test.ts' ,
37- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
38- Promise . resolve ( initialContent ) ,
39- )
35+ const result = await processStrReplace ( {
36+ path : 'test.ts' ,
37+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
38+ initialContentPromise : Promise . resolve ( initialContent ) ,
39+ } )
4040
4141 expect ( result ) . not . toBeNull ( )
4242 expect ( 'content' in result ) . toBe ( true )
@@ -52,11 +52,11 @@ describe('processStrReplace', () => {
5252 const oldStr = 'const y = 2;\r\n'
5353 const newStr = 'const y = 3;\r\n'
5454
55- const result = await processStrReplace (
56- 'test.ts' ,
57- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
58- Promise . resolve ( initialContent ) ,
59- )
55+ const result = await processStrReplace ( {
56+ path : 'test.ts' ,
57+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
58+ initialContentPromise : Promise . resolve ( initialContent ) ,
59+ } )
6060
6161 expect ( result ) . not . toBeNull ( )
6262 expect ( 'content' in result ) . toBe ( true )
@@ -71,11 +71,11 @@ describe('processStrReplace', () => {
7171 const oldStr = 'const y = 2;'
7272 const newStr = 'const y = 3;'
7373
74- const result = await processStrReplace (
75- 'test.ts' ,
76- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
77- Promise . resolve ( initialContent ) ,
78- )
74+ const result = await processStrReplace ( {
75+ path : 'test.ts' ,
76+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
77+ initialContentPromise : Promise . resolve ( initialContent ) ,
78+ } )
7979
8080 expect ( result ) . not . toBeNull ( )
8181 expect ( 'content' in result ) . toBe ( true )
@@ -89,11 +89,11 @@ describe('processStrReplace', () => {
8989 const oldStr = 'const y = 2;'
9090 const newStr = 'const y = 3;'
9191
92- const result = await processStrReplace (
93- 'test.ts' ,
94- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
95- Promise . resolve ( initialContent ) ,
96- )
92+ const result = await processStrReplace ( {
93+ path : 'test.ts' ,
94+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
95+ initialContentPromise : Promise . resolve ( initialContent ) ,
96+ } )
9797
9898 expect ( result ) . not . toBeNull ( )
9999 expect ( 'content' in result ) . toBe ( true )
@@ -103,11 +103,11 @@ describe('processStrReplace', () => {
103103 } )
104104
105105 it ( 'should return error if file content is null and oldStr is not empty' , async ( ) => {
106- const result = await processStrReplace (
107- 'test.ts' ,
108- [ { old : 'old' , new : 'new' , allowMultiple : false } ] ,
109- Promise . resolve ( null ) ,
110- )
106+ const result = await processStrReplace ( {
107+ path : 'test.ts' ,
108+ replacements : [ { old : 'old' , new : 'new' , allowMultiple : false } ] ,
109+ initialContentPromise : Promise . resolve ( null ) ,
110+ } )
111111
112112 expect ( result ) . not . toBeNull ( )
113113 expect ( 'error' in result ) . toBe ( true )
@@ -117,11 +117,11 @@ describe('processStrReplace', () => {
117117 } )
118118
119119 it ( 'should return error if oldStr is empty and file exists' , async ( ) => {
120- const result = await processStrReplace (
121- 'test.ts' ,
122- [ { old : '' , new : 'new' , allowMultiple : false } ] ,
123- Promise . resolve ( 'content' ) ,
124- )
120+ const result = await processStrReplace ( {
121+ path : 'test.ts' ,
122+ replacements : [ { old : '' , new : 'new' , allowMultiple : false } ] ,
123+ initialContentPromise : Promise . resolve ( 'content' ) ,
124+ } )
125125
126126 expect ( result ) . not . toBeNull ( )
127127 expect ( 'error' in result ) . toBe ( true )
@@ -135,11 +135,11 @@ describe('processStrReplace', () => {
135135 const oldStr = 'const z = 3;' // This string doesn't exist in the content
136136 const newStr = 'const z = 4;'
137137
138- const result = await processStrReplace (
139- 'test.ts' ,
140- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
141- Promise . resolve ( initialContent ) ,
142- )
138+ const result = await processStrReplace ( {
139+ path : 'test.ts' ,
140+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
141+ initialContentPromise : Promise . resolve ( initialContent ) ,
142+ } )
143143
144144 expect ( result ) . not . toBeNull ( )
145145 expect ( 'error' in result ) . toBe ( true )
@@ -155,11 +155,11 @@ describe('processStrReplace', () => {
155155 const oldStr = 'const x'
156156 const newStr = 'let x'
157157
158- const result = await processStrReplace (
159- 'test.ts' ,
160- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
161- Promise . resolve ( initialContent ) ,
162- )
158+ const result = await processStrReplace ( {
159+ path : 'test.ts' ,
160+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
161+ initialContentPromise : Promise . resolve ( initialContent ) ,
162+ } )
163163
164164 expect ( result ) . not . toBeNull ( )
165165 expect ( 'content' in result ) . toBe ( true )
@@ -173,11 +173,11 @@ describe('processStrReplace', () => {
173173 const oldStr = 'const y = 2;'
174174 const newStr = 'const y = 3;'
175175
176- const result = await processStrReplace (
177- 'test.ts' ,
178- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
179- Promise . resolve ( initialContent ) ,
180- )
176+ const result = await processStrReplace ( {
177+ path : 'test.ts' ,
178+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
179+ initialContentPromise : Promise . resolve ( initialContent ) ,
180+ } )
181181
182182 expect ( result ) . not . toBeNull ( )
183183 expect ( 'content' in result ) . toBe ( true )
@@ -194,11 +194,11 @@ describe('processStrReplace', () => {
194194 const oldStr = 'const y = "<div>";'
195195 const newStr = 'const y = "<span>";'
196196
197- const result = await processStrReplace (
198- 'test.ts' ,
199- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
200- Promise . resolve ( initialContent ) ,
201- )
197+ const result = await processStrReplace ( {
198+ path : 'test.ts' ,
199+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
200+ initialContentPromise : Promise . resolve ( initialContent ) ,
201+ } )
202202
203203 expect ( result ) . not . toBeNull ( )
204204 expect ( 'content' in result ) . toBe ( true )
@@ -217,11 +217,11 @@ describe('processStrReplace', () => {
217217 { old : 'const z = 3;' , new : 'const z = 30;' , allowMultiple : false } , // This also exists
218218 ]
219219
220- const result = await processStrReplace (
221- 'test.ts' ,
220+ const result = await processStrReplace ( {
221+ path : 'test.ts' ,
222222 replacements,
223- Promise . resolve ( initialContent ) ,
224- )
223+ initialContentPromise : Promise . resolve ( initialContent ) ,
224+ } )
225225
226226 expect ( result ) . not . toBeNull ( )
227227 expect ( 'content' in result ) . toBe ( true )
@@ -241,11 +241,11 @@ describe('processStrReplace', () => {
241241 const oldStr = 'const y = 2;'
242242 const newStr = 'const y = 2;' // Same as old string
243243
244- const result = await processStrReplace (
245- 'test.ts' ,
246- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
247- Promise . resolve ( initialContent ) ,
248- )
244+ const result = await processStrReplace ( {
245+ path : 'test.ts' ,
246+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
247+ initialContentPromise : Promise . resolve ( initialContent ) ,
248+ } )
249249
250250 expect ( result ) . not . toBeNull ( )
251251 expect ( 'content' in result ) . toBe ( true )
@@ -262,11 +262,11 @@ describe('processStrReplace', () => {
262262 const oldStr = 'const x'
263263 const newStr = 'let x'
264264
265- const result = await processStrReplace (
266- 'test.ts' ,
267- [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
268- Promise . resolve ( initialContent ) ,
269- )
265+ const result = await processStrReplace ( {
266+ path : 'test.ts' ,
267+ replacements : [ { old : oldStr , new : newStr , allowMultiple : false } ] ,
268+ initialContentPromise : Promise . resolve ( initialContent ) ,
269+ } )
270270
271271 expect ( result ) . not . toBeNull ( )
272272 expect ( 'error' in result ) . toBe ( true )
@@ -281,11 +281,11 @@ describe('processStrReplace', () => {
281281 const oldStr = 'foo'
282282 const newStr = 'FOO'
283283
284- const result = await processStrReplace (
285- 'test.ts' ,
286- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
287- Promise . resolve ( initialContent ) ,
288- )
284+ const result = await processStrReplace ( {
285+ path : 'test.ts' ,
286+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
287+ initialContentPromise : Promise . resolve ( initialContent ) ,
288+ } )
289289
290290 expect ( result ) . not . toBeNull ( )
291291 expect ( 'content' in result ) . toBe ( true )
@@ -299,11 +299,11 @@ describe('processStrReplace', () => {
299299 const oldStr = 'const y = 2;'
300300 const newStr = 'const y = 3;'
301301
302- const result = await processStrReplace (
303- 'test.ts' ,
304- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
305- Promise . resolve ( initialContent ) ,
306- )
302+ const result = await processStrReplace ( {
303+ path : 'test.ts' ,
304+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
305+ initialContentPromise : Promise . resolve ( initialContent ) ,
306+ } )
307307
308308 expect ( result ) . not . toBeNull ( )
309309 expect ( 'content' in result ) . toBe ( true )
@@ -320,11 +320,11 @@ describe('processStrReplace', () => {
320320 { old : 'qux qux' , new : 'QUX' , allowMultiple : false } , // Single occurrence, should work
321321 ]
322322
323- const result = await processStrReplace (
324- 'test.ts' ,
323+ const result = await processStrReplace ( {
324+ path : 'test.ts' ,
325325 replacements,
326- Promise . resolve ( initialContent ) ,
327- )
326+ initialContentPromise : Promise . resolve ( initialContent ) ,
327+ } )
328328
329329 expect ( result ) . not . toBeNull ( )
330330 expect ( 'content' in result ) . toBe ( true )
@@ -351,11 +351,11 @@ function test3() {
351351 const oldStr = "console.log('debug');"
352352 const newStr = '// removed debug log'
353353
354- const result = await processStrReplace (
355- 'test.ts' ,
356- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
357- Promise . resolve ( initialContent ) ,
358- )
354+ const result = await processStrReplace ( {
355+ path : 'test.ts' ,
356+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
357+ initialContentPromise : Promise . resolve ( initialContent ) ,
358+ } )
359359
360360 expect ( result ) . not . toBeNull ( )
361361 expect ( 'content' in result ) . toBe ( true )
@@ -374,11 +374,11 @@ function test3() {
374374 const oldStr = 'remove this, '
375375 const newStr = ''
376376
377- const result = await processStrReplace (
378- 'test.ts' ,
379- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
380- Promise . resolve ( initialContent ) ,
381- )
377+ const result = await processStrReplace ( {
378+ path : 'test.ts' ,
379+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
380+ initialContentPromise : Promise . resolve ( initialContent ) ,
381+ } )
382382
383383 expect ( result ) . not . toBeNull ( )
384384 expect ( 'content' in result ) . toBe ( true )
@@ -397,11 +397,11 @@ function test3() {
397397 const oldStr = 'doSomething();'
398398 const newStr = 'doSomethingElse();'
399399
400- const result = await processStrReplace (
401- 'test.ts' ,
402- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
403- Promise . resolve ( initialContent ) ,
404- )
400+ const result = await processStrReplace ( {
401+ path : 'test.ts' ,
402+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
403+ initialContentPromise : Promise . resolve ( initialContent ) ,
404+ } )
405405
406406 expect ( result ) . not . toBeNull ( )
407407 expect ( 'content' in result ) . toBe ( true )
@@ -416,11 +416,11 @@ function test3() {
416416 const oldStr = 'const z = 3;' // This string doesn't exist
417417 const newStr = 'const z = 4;'
418418
419- const result = await processStrReplace (
420- 'test.ts' ,
421- [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
422- Promise . resolve ( initialContent ) ,
423- )
419+ const result = await processStrReplace ( {
420+ path : 'test.ts' ,
421+ replacements : [ { old : oldStr , new : newStr , allowMultiple : true } ] ,
422+ initialContentPromise : Promise . resolve ( initialContent ) ,
423+ } )
424424
425425 expect ( result ) . not . toBeNull ( )
426426 expect ( 'error' in result ) . toBe ( true )
@@ -447,11 +447,11 @@ function test3() {
447447 } ,
448448 ]
449449
450- const result = await processStrReplace (
451- 'test.ts' ,
450+ const result = await processStrReplace ( {
451+ path : 'test.ts' ,
452452 replacements,
453- Promise . resolve ( initialContent ) ,
454- )
453+ initialContentPromise : Promise . resolve ( initialContent ) ,
454+ } )
455455
456456 expect ( 'content' in result ) . toBe ( true )
457457 expect ( applyPatch ( initialContent , ( result as any ) . patch ) ) . toBe (
0 commit comments