Skip to content

Commit 71b39ff

Browse files
committed
Clear packumentCache after each package
1 parent fec7760 commit 71b39ff

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/commands/fix/npm-fix.mts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ export async function npmFix(
154154
return { ok: true, data: { fixed: false } }
155155
}
156156

157-
// baseBranch and branchParser are now from env
157+
// Lazily access constants.packumentCache.
158+
const { packumentCache } = constants
159+
158160
const workspacePkgJsonPaths = await globWorkspace(
159161
pkgEnvDetails.agent,
160162
rootPath,
@@ -168,11 +170,14 @@ export async function npmFix(
168170
naturalCompare(a[0], b[0]),
169171
)
170172

171-
const handleInstallFail = (): CResult<{ fixed: boolean }> => {
172-
debugFn(`fail: ${pkgEnvDetails.agent} install\n`)
173+
const cleanupInfoEntriesLoop = () => {
173174
logger.dedent()
174175
spinner?.dedent()
176+
packumentCache.clear()
177+
}
175178

179+
const handleInstallFail = (): CResult<{ fixed: boolean }> => {
180+
cleanupInfoEntriesLoop()
176181
return {
177182
ok: false,
178183
message: 'Installation failure',
@@ -214,8 +219,7 @@ export async function npmFix(
214219
const packument = await fetchPackagePackument(name)
215220
if (!packument) {
216221
logger.warn(`Unexpected condition: No packument found for ${name}.\n`)
217-
logger.dedent()
218-
spinner?.dedent()
222+
cleanupInfoEntriesLoop()
219223
continue infoEntriesLoop
220224
}
221225

@@ -249,8 +253,7 @@ export async function npmFix(
249253
if (!oldVersions.length) {
250254
debugFn(`skip: ${name} not found\n`)
251255
// Skip to next package.
252-
logger.dedent()
253-
spinner?.dedent()
256+
cleanupInfoEntriesLoop()
254257
continue infoEntriesLoop
255258
}
256259

@@ -312,8 +315,7 @@ export async function npmFix(
312315
) {
313316
debugFn(`skip: open PR found for ${name}@${newVersion}`)
314317
if (++count >= limit) {
315-
logger.dedent()
316-
spinner?.dedent()
318+
cleanupInfoEntriesLoop()
317319
break infoEntriesLoop
318320
}
319321
continue infosLoop
@@ -554,8 +556,7 @@ export async function npmFix(
554556
logger.fail(`Update failed for ${oldId} in ${workspace}.`, error)
555557
}
556558
if (++count >= limit) {
557-
logger.dedent()
558-
spinner?.dedent()
559+
cleanupInfoEntriesLoop()
559560
break infoEntriesLoop
560561
}
561562
}
@@ -571,8 +572,7 @@ export async function npmFix(
571572
if (!isLastInfoEntry) {
572573
logger.logNewline()
573574
}
574-
logger.dedent()
575-
spinner?.dedent()
575+
cleanupInfoEntriesLoop()
576576
}
577577

578578
spinner?.stop()

src/commands/fix/pnpm-fix.mts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ export async function pnpmFix(
230230
return { ok: true, data: { fixed: false } }
231231
}
232232

233-
// baseBranch and branchParser are now from env
233+
// Lazily access constants.packumentCache.
234+
const { packumentCache } = constants
235+
234236
const workspacePkgJsonPaths = await globWorkspace(
235237
pkgEnvDetails.agent,
236238
rootPath,
@@ -244,10 +246,14 @@ export async function pnpmFix(
244246
naturalCompare(a[0], b[0]),
245247
)
246248

247-
const handleInstallFail = (): CResult<{ fixed: boolean }> => {
249+
const cleanupInfoEntriesLoop = () => {
248250
logger.dedent()
249251
spinner?.dedent()
252+
packumentCache.clear()
253+
}
250254

255+
const handleInstallFail = (): CResult<{ fixed: boolean }> => {
256+
cleanupInfoEntriesLoop()
251257
return {
252258
ok: false,
253259
message: 'Install failed',
@@ -289,8 +295,7 @@ export async function pnpmFix(
289295
const packument = await fetchPackagePackument(name)
290296
if (!packument) {
291297
logger.warn(`Unexpected condition: No packument found for ${name}.\n`)
292-
logger.dedent()
293-
spinner?.dedent()
298+
cleanupInfoEntriesLoop()
294299
continue infoEntriesLoop
295300
}
296301

@@ -350,8 +355,7 @@ export async function pnpmFix(
350355
if (!oldVersions.length) {
351356
debugFn(`skip: ${name} not found\n`)
352357
// Skip to next package.
353-
logger.dedent()
354-
spinner?.dedent()
358+
cleanupInfoEntriesLoop()
355359
continue infoEntriesLoop
356360
}
357361

@@ -420,8 +424,7 @@ export async function pnpmFix(
420424
) {
421425
debugFn(`skip: open PR found for ${name}@${newVersion}`)
422426
if (++count >= limit) {
423-
logger.dedent()
424-
spinner?.dedent()
427+
cleanupInfoEntriesLoop()
425428
break infoEntriesLoop
426429
}
427430
continue infosLoop
@@ -753,8 +756,7 @@ export async function pnpmFix(
753756
debugFn('name:', name)
754757
debugFn('increment: count', count + 1)
755758
if (++count >= limit) {
756-
logger.dedent()
757-
spinner?.dedent()
759+
cleanupInfoEntriesLoop()
758760
break infoEntriesLoop
759761
}
760762
}
@@ -770,8 +772,7 @@ export async function pnpmFix(
770772
if (!isLastInfoEntry) {
771773
logger.logNewline()
772774
}
773-
logger.dedent()
774-
spinner?.dedent()
775+
cleanupInfoEntriesLoop()
775776
}
776777

777778
spinner?.stop()

0 commit comments

Comments
 (0)