transformComponentContent function

String transformComponentContent(
  1. String content,
  2. String destinationPath,
  3. String cwd
)

Implementation

String transformComponentContent(
  String content,
  String destinationPath,
  String cwd,
) {
  final themePath = path.join(cwd, 'lib', 'config', 'theme.dart');
  final importPath = calculateThemeImportPath(destinationPath, themePath);
  final importRegex = RegExp(
    "import\\s+(['\"])(\\.\\.\\/)*config\\/theme\\.dart(['\"]);?",
    multiLine: true,
  );
  final newImport = "import '$importPath';";

  return content.replaceAll(importRegex, newImport);
}