Skip to content

Commit a6ad248

Browse files
authored
Add line breaks in between processing groups for fix (#561)
1 parent 4f3fd8c commit a6ad248

4 files changed

Lines changed: 31 additions & 11 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"@socketregistry/is-interactive": "1.0.5",
108108
"@socketregistry/packageurl-js": "1.0.6",
109109
"@socketsecurity/config": "2.1.3",
110-
"@socketsecurity/registry": "1.0.183",
110+
"@socketsecurity/registry": "1.0.184",
111111
"@socketsecurity/sdk": "1.4.36",
112112
"@types/blessed": "0.1.25",
113113
"@types/cmd-shim": "5.0.2",

src/commands/fix/npm-fix.mts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ export async function npmFix(
137137
const sortedInfoEntries = [...infoByPkgName.entries()].sort((a, b) =>
138138
naturalCompare(a[0], b[0])
139139
)
140-
infoEntriesLoop: for (const { 0: name, 1: infos } of sortedInfoEntries) {
140+
infoEntriesLoop: for (
141+
let i = 0, { length } = sortedInfoEntries;
142+
i < length;
143+
i += 1
144+
) {
145+
const { 0: name, 1: infos } = sortedInfoEntries[i]!
146+
const isLastInfoEntry = i === length - 1
147+
141148
logger.log(`Processing vulnerable package: ${name}`)
142149
logger.indent()
143150
spinner?.indent()
@@ -166,6 +173,7 @@ export async function npmFix(
166173
: path.relative(rootPath, pkgPath)
167174

168175
logger.log(`Checking workspace: ${workspaceName}`)
176+
const workspaceLogCallCount = logger.logCallCount
169177

170178
// eslint-disable-next-line no-await-in-loop
171179
actualTree = await install(arb, { cwd })
@@ -389,13 +397,15 @@ export async function npmFix(
389397
}
390398
}
391399
}
392-
logger.log('')
400+
if (logger.logCallCount > workspaceLogCallCount) {
401+
logger.log('')
402+
}
393403
}
394404

395405
for (const warningText of warningsForAfter) {
396406
logger.warn(warningText)
397407
}
398-
if (warningsForAfter.size) {
408+
if (!isLastInfoEntry) {
399409
logger.log('')
400410
}
401411

src/commands/fix/pnpm-fix.mts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ export async function pnpmFix(
197197
const sortedInfoEntries = [...infoByPkgName.entries()].sort((a, b) =>
198198
naturalCompare(a[0], b[0])
199199
)
200-
infoEntriesLoop: for (const { 0: name, 1: infos } of sortedInfoEntries) {
200+
infoEntriesLoop: for (
201+
let i = 0, { length } = sortedInfoEntries;
202+
i < length;
203+
i += 1
204+
) {
205+
const { 0: name, 1: infos } = sortedInfoEntries[i]!
206+
const isLastInfoEntry = i === length - 1
207+
201208
logger.log(`Processing vulnerable package: ${name}`)
202209
logger.indent()
203210
spinner?.indent()
@@ -226,6 +233,7 @@ export async function pnpmFix(
226233
: path.relative(rootPath, pkgPath)
227234

228235
logger.log(`Checking workspace: ${workspaceName}`)
236+
const workspaceLogCallCount = logger.logCallCount
229237

230238
// eslint-disable-next-line no-await-in-loop
231239
actualTree = await install(pkgEnvDetails, { cwd, spinner })
@@ -488,13 +496,15 @@ export async function pnpmFix(
488496
}
489497
}
490498
}
491-
logger.log('')
499+
if (logger.logCallCount > workspaceLogCallCount) {
500+
logger.log('')
501+
}
492502
}
493503

494504
for (const warningText of warningsForAfter) {
495505
logger.warn(warningText)
496506
}
497-
if (warningsForAfter.size) {
507+
if (!isLastInfoEntry) {
498508
logger.log('')
499509
}
500510

0 commit comments

Comments
 (0)