copyGeneratedCodesFor method

Future<void> copyGeneratedCodesFor(
  1. List<CodeFile> files
)

Implementation

Future<void> copyGeneratedCodesFor(List<CodeFile> files) async {
  Logger.i('Copying cached files to project directory (${files.length} total)');

  for (final file in files) {
    final cachedGeneratedCodePath = await _dbOperation(
      (db) async => await db.getCachedFilePath(file.digest),
    );
    final generatedFilePath = file.getGeneratedFilePath();

    Logger.v('Copying file: ${Utils.getFileName(generatedFilePath)}');
    final copiedFile = File(cachedGeneratedCodePath).copySync(generatedFilePath);

    /// check if the file was copied successfully
    if (!copiedFile.existsSync()) {
      Logger.e(
        'ERROR: _copyGeneratedCodesFor: failed to copy the cached file $file',
      );
    }
  }
}