@@ -142,6 +142,28 @@ impl PackageManager {
142142 }
143143 }
144144 }
145+ PackageManagerType :: Bun => {
146+ bin_name = "bun" . into ( ) ;
147+ args. push ( "audit" . into ( ) ) ;
148+
149+ if options. fix {
150+ output:: warn ( "bun audit does not support --fix" ) ;
151+ return None ;
152+ }
153+
154+ if let Some ( level) = options. level {
155+ args. push ( "--audit-level" . into ( ) ) ;
156+ args. push ( level. to_string ( ) ) ;
157+ }
158+
159+ if options. production {
160+ output:: warn ( "--production not supported by bun audit, ignoring flag" ) ;
161+ }
162+
163+ if options. json {
164+ args. push ( "--json" . into ( ) ) ;
165+ }
166+ }
145167 }
146168
147169 // Add pass-through args
@@ -320,6 +342,70 @@ mod tests {
320342 assert_eq ! ( result. args, vec![ "audit" , "--level" , "high" ] ) ;
321343 }
322344
345+ #[ test]
346+ fn test_bun_audit_basic ( ) {
347+ let pm = create_mock_package_manager ( PackageManagerType :: Bun , "1.3.11" ) ;
348+ let result = pm. resolve_audit_command ( & AuditCommandOptions {
349+ fix : false ,
350+ json : false ,
351+ level : None ,
352+ production : false ,
353+ pass_through_args : None ,
354+ } ) ;
355+ assert ! ( result. is_some( ) ) ;
356+ let result = result. unwrap ( ) ;
357+ assert_eq ! ( result. bin_path, "bun" ) ;
358+ assert ! ( result. args. contains( & "audit" . to_string( ) ) , "should contain 'audit'" ) ;
359+ assert ! ( !result. args. contains( & "pm" . to_string( ) ) , "should NOT use 'bun pm audit'" ) ;
360+ }
361+
362+ #[ test]
363+ fn test_bun_audit_level ( ) {
364+ let pm = create_mock_package_manager ( PackageManagerType :: Bun , "1.3.11" ) ;
365+ let result = pm. resolve_audit_command ( & AuditCommandOptions {
366+ fix : false ,
367+ json : false ,
368+ level : Some ( "high" ) ,
369+ production : false ,
370+ pass_through_args : None ,
371+ } ) ;
372+ assert ! ( result. is_some( ) ) ;
373+ let result = result. unwrap ( ) ;
374+ assert ! (
375+ result. args. contains( & "--audit-level" . to_string( ) ) ,
376+ "should use --audit-level not --level"
377+ ) ;
378+ assert ! ( result. args. contains( & "high" . to_string( ) ) ) ;
379+ }
380+
381+ #[ test]
382+ fn test_bun_audit_fix_not_supported ( ) {
383+ let pm = create_mock_package_manager ( PackageManagerType :: Bun , "1.3.11" ) ;
384+ let result = pm. resolve_audit_command ( & AuditCommandOptions {
385+ fix : true ,
386+ json : false ,
387+ level : None ,
388+ production : false ,
389+ pass_through_args : None ,
390+ } ) ;
391+ assert ! ( result. is_none( ) ) ;
392+ }
393+
394+ #[ test]
395+ fn test_bun_audit_json ( ) {
396+ let pm = create_mock_package_manager ( PackageManagerType :: Bun , "1.3.11" ) ;
397+ let result = pm. resolve_audit_command ( & AuditCommandOptions {
398+ fix : false ,
399+ json : true ,
400+ level : None ,
401+ production : false ,
402+ pass_through_args : None ,
403+ } ) ;
404+ assert ! ( result. is_some( ) ) ;
405+ let result = result. unwrap ( ) ;
406+ assert_eq ! ( result. args, vec![ "audit" , "--json" ] ) ;
407+ }
408+
323409 #[ test]
324410 fn test_audit_with_level_yarn2 ( ) {
325411 let pm = create_mock_package_manager ( PackageManagerType :: Yarn , "4.0.0" ) ;
0 commit comments