LCOV - code coverage report
Current view: top level - src/cli - dart_cli.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 14 14 100.0 %
Date: 2023-11-15 10:29:52 Functions: 0 0 -

          Line data    Source code
       1             : part of 'cli.dart';
       2             : 
       3             : /// Dart CLI
       4             : class Dart {
       5             :   /// Determine whether dart is installed.
       6           7 :   static Future<bool> installed({
       7             :     required Logger logger,
       8             :   }) async {
       9             :     try {
      10          14 :       await _Cmd.run('dart', ['--version'], logger: logger);
      11             :       return true;
      12             :     } catch (_) {
      13             :       return false;
      14             :     }
      15             :   }
      16             : 
      17             :   /// Apply all fixes (`dart fix --apply`).
      18           7 :   static Future<void> applyFixes({
      19             :     required Logger logger,
      20             :     String cwd = '.',
      21             :     bool recursive = false,
      22             :     Set<String> ignore = const {},
      23             :   }) async {
      24             :     if (!recursive) {
      25          12 :       final pubspec = File(p.join(cwd, 'pubspec.yaml'));
      26           6 :       if (!pubspec.existsSync()) throw PubspecNotFound();
      27             : 
      28           6 :       await _Cmd.run(
      29             :         'dart',
      30           6 :         ['fix', '--apply'],
      31             :         workingDirectory: cwd,
      32             :         logger: logger,
      33             :       );
      34             :       return;
      35             :     }
      36             : 
      37           1 :     final processes = _Cmd.runWhere(
      38           2 :       run: (entity) => _Cmd.run(
      39             :         'dart',
      40           1 :         ['fix', '--apply'],
      41           2 :         workingDirectory: entity.parent.path,
      42             :         logger: logger,
      43             :       ),
      44           3 :       where: (entity) => !ignore.excludes(entity) && _isPubspec(entity),
      45             :       cwd: cwd,
      46             :     );
      47             : 
      48           1 :     if (processes.isEmpty) throw PubspecNotFound();
      49             : 
      50           1 :     await Future.wait<void>(processes);
      51             :   }
      52             : }

Generated by: LCOV version 1.16