addNewAppsInLocator method

void addNewAppsInLocator(
  1. String pathApps,
  2. String appsName
)

Implementation

void addNewAppsInLocator(String pathApps, String appsName) {
  if (!exists(join(current, 'lib', 'locator.dart'))) {
    return;
  }
  String locator =
      File(join(current, 'lib', 'locator.dart')).readAsStringSync();

  locator = locator.replaceAll(
    RegExp(r'(^(\s+)?void setup)', multiLine: true),
    '''import 'package:$appsName/locator.dart';

void setup''',
  );
  locator = locator.replaceAll(
    '}',
    '''  setupLocatorApps${appsName.pascalCase}();
}''',
  );
  join(current, 'lib', 'locator.dart').write(locator);

  StatusHelper.generated(join(current, 'lib', 'locator.dart'));
}