Skip to content

Commit 76a56aa

Browse files
committed
More cleanup
1 parent 2ee545f commit 76a56aa

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/commands/scan/cmd-scan-create.mts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'node:path'
22

3+
import { joinAnd } from '@socketsecurity/registry/lib/arrays'
34
import { logger } from '@socketsecurity/registry/lib/logger'
45

56
import { handleCreateNewScan } from './handle-create-new-scan.mts'
@@ -256,7 +257,7 @@ async function run(
256257
for (const ecosystem of reachEcosystemsRaw) {
257258
if (!validEcosystems.includes(ecosystem)) {
258259
throw new Error(
259-
`Invalid ecosystem: "${ecosystem}". Valid values are: ${validEcosystems.join(', ')}`,
260+
`Invalid ecosystem: "${ecosystem}". Valid values are: ${joinAnd(validEcosystems)}`,
260261
)
261262
}
262263
reachEcosystems.push(ecosystem as PURL_Type)
@@ -418,7 +419,7 @@ async function run(
418419
nook: true,
419420
test: hasApiToken,
420421
message: 'This command requires an API token for access',
421-
fail: 'missing (try `socket login`)',
422+
fail: 'try `socket login`',
422423
},
423424
{
424425
nook: true,
@@ -439,7 +440,6 @@ async function run(
439440
reachDisableAnalytics ===
440441
reachabilityFlags['reachDisableAnalytics']?.default,
441442
message: 'The --reachDisableAnalytics flag requires --reach to be set',
442-
pass: 'ok',
443443
fail: 'missing --reach flag',
444444
},
445445
{
@@ -449,7 +449,6 @@ async function run(
449449
reachAnalysisMemoryLimit ===
450450
reachabilityFlags['reachAnalysisMemoryLimit']?.default,
451451
message: 'The --reachAnalysisMemoryLimit flag requires --reach to be set',
452-
pass: 'ok',
453452
fail: 'missing --reach flag',
454453
},
455454
{
@@ -459,29 +458,25 @@ async function run(
459458
reachAnalysisTimeout ===
460459
reachabilityFlags['reachAnalysisTimeout']?.default,
461460
message: 'The --reachAnalysisTimeout flag requires --reach to be set',
462-
pass: 'ok',
463461
fail: 'missing --reach flag',
464462
},
465463
{
466464
nook: true,
467465
test: reach || !reachEcosystems.length,
468466
message: 'The --reachEcosystems flag requires --reach to be set',
469-
pass: 'ok',
470467
fail: 'missing --reach flag',
471468
},
472469
{
473470
nook: true,
474471
test: reach || !reachContinueOnFailingProjects,
475472
message:
476473
'The --reachContinueOnFailingProjects flag requires --reach to be set',
477-
pass: 'ok',
478474
fail: 'missing --reach flag',
479475
},
480476
{
481477
nook: true,
482478
test: reach || !reachExcludePaths.length,
483479
message: 'The --reachExcludePaths flag requires --reach to be set',
484-
pass: 'ok',
485480
fail: 'missing --reach flag',
486481
},
487482
)

src/commands/scan/cmd-scan-reach.mts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import path from 'node:path'
22

3+
import { joinAnd } from '@socketsecurity/registry/lib/arrays'
34
import { logger } from '@socketsecurity/registry/lib/logger'
45

56
import { handleScanReach } from './handle-scan-reach.mts'
67
import { reachabilityFlags } from './reachability-flags.mts'
78
import { suggestTarget } from './suggest_target.mts'
89
import constants from '../../constants.mts'
9-
import { type MeowFlags, commonFlags, outputFlags } from '../../flags.mts'
10+
import { commonFlags, outputFlags } from '../../flags.mts'
1011
import { checkCommandInput } from '../../utils/check-input.mts'
1112
import { cmdFlagValueToArray } from '../../utils/cmd.mts'
1213
import { determineOrgSlug } from '../../utils/determine-org-slug.mts'
@@ -16,6 +17,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
1617
import { getFlagListOutput } from '../../utils/output-formatting.mts'
1718
import { hasDefaultToken } from '../../utils/sdk.mts'
1819

20+
import type { MeowFlags } from '../../flags.mts'
1921
import type { PURL_Type } from '../../utils/ecosystem.mts'
2022
import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts'
2123

@@ -120,14 +122,12 @@ async function run(
120122
for (const ecosystem of reachEcosystemsRaw) {
121123
if (!validEcosystems.includes(ecosystem)) {
122124
throw new Error(
123-
`Invalid ecosystem: "${ecosystem}". Valid values are: ${validEcosystems.join(', ')}`,
125+
`Invalid ecosystem: "${ecosystem}". Valid values are: ${joinAnd(validEcosystems)}`,
124126
)
125127
}
126128
reachEcosystems.push(ecosystem as PURL_Type)
127129
}
128130

129-
const outputKind = getOutputKind(json, markdown)
130-
131131
const cwd =
132132
cwdOverride && cwdOverride !== 'process.cwd()'
133133
? path.resolve(process.cwd(), String(cwdOverride))
@@ -150,6 +150,8 @@ async function run(
150150

151151
const hasApiToken = hasDefaultToken()
152152

153+
const outputKind = getOutputKind(json, markdown)
154+
153155
const wasValidInput = checkCommandInput(
154156
outputKind,
155157
{
@@ -162,7 +164,7 @@ async function run(
162164
nook: true,
163165
test: hasApiToken,
164166
message: 'This command requires an API token for access',
165-
fail: 'missing (try `socket login`)',
167+
fail: 'try `socket login`',
166168
},
167169
)
168170
if (!wasValidInput) {

0 commit comments

Comments
 (0)