call method

Future<File> call()

Implementation

Future<File> call() async {
  final fileSytemEntities =
      await _helper.getFileSystemEntities(Directory(_sourceDirectory));

  final candidateFiles =
      await _helper.getOnlyCandidateFiles(fileSytemEntities);

  final filteredFilePaths = _helper.getFilteredFilePaths(
      candidateFiles,
      _config.excludeSuffixes,
      _config.excludeFiles,
      _config.excludeContents,
      _config.excludeContentsPath);

  final fileImports = [
    '/*\n'
        'Do not edit this file manually, it is overwritten every time dlcov\n'
        'runs, in order to make coverage work for all dart files\n'
        '*/\n',
  ];

  fileImports.add('// ignore_for_file: unused_import');

  fileImports.addAll(filteredFilePaths
      .map((path) =>
          "import 'package:$_packageName${path.replaceFirst(_sourceDirectory, '').replaceAll('\\', '/')}';")
      .toList());

  fileImports.add('void main(){}');

  final allFilesReferences = fileImports.join('\n');

  return await _helper.writeContentToFile(
      allFilesReferences, AppConstants.dlcovFileReferences);
}