Skip to content

Commit 963308d

Browse files
authored
Avoid double installing for fix (#654)
1 parent bcee9b5 commit 963308d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/commands/fix/npm-fix.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export async function npmFix(
263263
const editablePkgJson = await readPackageJson(pkgJsonPath, {
264264
editable: true,
265265
})
266+
const fixedVersions = new Set<string>()
266267

267268
let hasAnnouncedWorkspace = false
268269
let workspaceLogCallCount = logger.logCallCount
@@ -301,12 +302,13 @@ export async function npmFix(
301302
)
302303
continue infosLoop
303304
}
304-
305+
if (fixedVersions.has(newVersion)) {
306+
continue infosLoop
307+
}
305308
if (semver.gte(oldVersion, newVersion)) {
306309
debugFn(`skip: ${oldId} is >= ${newVersion}`)
307310
continue infosLoop
308311
}
309-
310312
if (
311313
activeBranches.find(
312314
b =>
@@ -379,6 +381,7 @@ export async function npmFix(
379381
await runScript(testScript, [], { spinner, stdio: 'ignore' })
380382
}
381383
spinner?.success(`Fixed ${name} in ${workspace}.`)
384+
fixedVersions.add(newVersion)
382385
} else {
383386
errored = true
384387
}

src/commands/fix/pnpm-fix.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ export async function pnpmFix(
365365
const editablePkgJson = await readPackageJson(pkgJsonPath, {
366366
editable: true,
367367
})
368+
const fixedVersions = new Set<string>()
369+
368370
// Get current overrides for revert logic.
369371
const oldPnpmSection = editablePkgJson.content[PNPM] as
370372
| StringKeyValueObject
@@ -410,12 +412,13 @@ export async function pnpmFix(
410412
)
411413
continue infosLoop
412414
}
413-
415+
if (fixedVersions.has(newVersion)) {
416+
continue infosLoop
417+
}
414418
if (semver.gte(oldVersion, newVersion)) {
415419
debugFn(`skip: ${oldId} is >= ${newVersion}`)
416420
continue infosLoop
417421
}
418-
419422
if (
420423
activeBranches.find(
421424
b =>
@@ -553,6 +556,7 @@ export async function pnpmFix(
553556
await runScript(testScript, [], { spinner, stdio: 'ignore' })
554557
}
555558
spinner?.success(`Fixed ${name} in ${workspace}.`)
559+
fixedVersions.add(newVersion)
556560
} else {
557561
errored = true
558562
}

0 commit comments

Comments
 (0)