Skip to content

Commit 2ce39b3

Browse files
committed
Pass path args to cdxgen
1 parent f4f3b3d commit 2ce39b3

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

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
@@ -111,7 +111,7 @@
111111
"@socketregistry/is-interactive": "1.0.6",
112112
"@socketregistry/packageurl-js": "1.0.8",
113113
"@socketsecurity/config": "3.0.1",
114-
"@socketsecurity/registry": "1.0.262",
114+
"@socketsecurity/registry": "1.0.263",
115115
"@socketsecurity/sdk": "1.4.70",
116116
"@types/blessed": "0.1.25",
117117
"@types/cmd-shim": "5.0.2",

src/commands/manifest/cmd-manifest-cdxgen.mts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import terminalLink from 'terminal-link'
22
import yargsParse from 'yargs-parser'
33

44
import { logger } from '@socketsecurity/registry/lib/logger'
5+
import { isPath } from '@socketsecurity/registry/lib/path'
56
import { pluralize } from '@socketsecurity/registry/lib/words'
67

78
import { runCdxgen } from './run-cdxgen.mts'
@@ -252,15 +253,26 @@ async function run(
252253
...yargsParse(argv as string[], yargsConfig),
253254
} as any
254255

255-
const unknown: string[] = yargv._
256-
const { length: unknownLength } = unknown
257-
if (unknownLength) {
256+
const pathArgs: string[] = []
257+
const unknowns: string[] = []
258+
for (const a of yargv._) {
259+
if (isPath(a)) {
260+
pathArgs.push(a)
261+
} else {
262+
unknowns.push(a)
263+
}
264+
}
265+
266+
yargv._ = pathArgs
267+
268+
const { length: unknownsCount } = unknowns
269+
if (unknownsCount) {
258270
// Use exit status of 2 to indicate incorrect usage, generally invalid
259271
// options or missing arguments.
260272
// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
261273
process.exitCode = 2
262274
logger.fail(
263-
`Unknown ${pluralize('argument', unknownLength)}: ${yargv._.join(', ')}`,
275+
`Unknown ${pluralize('argument', unknownsCount)}: ${unknowns.join(', ')}`,
264276
)
265277
return
266278
}

src/commands/manifest/run-cdxgen.mts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ function argvToArray(argv: {
4444
result.push(`--${key}`, ...value.map(String))
4545
}
4646
}
47-
if (argv['--']) {
48-
result.push('--', ...(argv as any)['--'])
47+
const pathArgs = argv['_'] as string[]
48+
if (Array.isArray(pathArgs)) {
49+
result.push(...pathArgs)
50+
}
51+
const argsAfterDoubleHyphen = argv['--'] as string[]
52+
if (Array.isArray(argsAfterDoubleHyphen)) {
53+
result.push('--', ...argsAfterDoubleHyphen)
4954
}
5055
return result
5156
}

0 commit comments

Comments
 (0)