@@ -21,7 +21,36 @@ const nodejsPlatformTypes = new Set([
2121 'typescript'
2222] )
2323
24- export async function runCycloneDX ( yargvWithYes : any ) {
24+ function argvToArray ( argv : {
25+ [ key : string ] : boolean | null | number | string | Array < string | number >
26+ } ) : string [ ] {
27+ if ( argv [ 'help' ] ) {
28+ return [ '--help' ]
29+ }
30+ const result = [ ]
31+ for ( const { 0 : key , 1 : value } of Object . entries ( argv ) ) {
32+ if ( key === '_' || key === '--' ) {
33+ continue
34+ }
35+ if ( key === 'babel' || key === 'install-deps' || key === 'validate' ) {
36+ // cdxgen documents no-babel, no-install-deps, and no-validate flags so
37+ // use them when relevant.
38+ result . push ( `--${ value ? key : `no-${ key } ` } ` )
39+ } else if ( value === true ) {
40+ result . push ( `--${ key } ` )
41+ } else if ( typeof value === 'string' ) {
42+ result . push ( `--${ key } ` , String ( value ) )
43+ } else if ( Array . isArray ( value ) ) {
44+ result . push ( `--${ key } ` , ...value . map ( String ) )
45+ }
46+ }
47+ if ( argv [ '--' ] ) {
48+ result . push ( '--' , ...( argv as any ) [ '--' ] )
49+ }
50+ return result
51+ }
52+
53+ export async function runCdxgen ( yargvWithYes : any ) {
2554 let cleanupPackageLock = false
2655 const { yes, ...yargv } = { __proto__ : null , ...yargvWithYes } as any
2756 const yesArgs = yes ? [ '--yes' ] : [ ]
@@ -64,32 +93,3 @@ export async function runCycloneDX(yargvWithYes: any) {
6493 logger . log ( colors . cyanBright ( `${ yargv . output } created!` ) )
6594 }
6695}
67-
68- function argvToArray ( argv : {
69- [ key : string ] : boolean | null | number | string | Array < string | number >
70- } ) : string [ ] {
71- if ( argv [ 'help' ] ) {
72- return [ '--help' ]
73- }
74- const result = [ ]
75- for ( const { 0 : key , 1 : value } of Object . entries ( argv ) ) {
76- if ( key === '_' || key === '--' ) {
77- continue
78- }
79- if ( key === 'babel' || key === 'install-deps' || key === 'validate' ) {
80- // cdxgen documents no-babel, no-install-deps, and no-validate flags so
81- // use them when relevant.
82- result . push ( `--${ value ? key : `no-${ key } ` } ` )
83- } else if ( value === true ) {
84- result . push ( `--${ key } ` )
85- } else if ( typeof value === 'string' ) {
86- result . push ( `--${ key } ` , String ( value ) )
87- } else if ( Array . isArray ( value ) ) {
88- result . push ( `--${ key } ` , ...value . map ( String ) )
89- }
90- }
91- if ( argv [ '--' ] ) {
92- result . push ( '--' , ...( argv as any ) [ '--' ] )
93- }
94- return result
95- }
0 commit comments