init method

Implementation

Future<CachedBuildRunner> init() async {
  /// the project directory is always where the `flutter run` command is executed
  /// which is the current directory
  Utils.projectDirectory =
      Platform.environment['CACHED_BUILD_RUNNER_PROJECT_DIRECTORY'] ??
          Directory.current.path;

  /// let's make the appCacheDirectory if not existing already
  Directory(Utils.appCacheDirectory).createSync(recursive: true);

  /// init package name of project
  Utils.initAppPackageName();

  /// initialize the database
  final databaseService = Utils.isRedisUsed
      ? RedisDatabaseService()
      : HiveDatabaseService(Utils.appCacheDirectory);
  await databaseService.init();

  /// let's initiate the build
  return CachedBuildRunner(databaseService);
}