getContentDirectory function Null safety

Future<Either<BuildError, Directory>> getContentDirectory(
  1. Config config
)

Content directory contains Markdown files.

Config: build.content_dir

Implementation

Future<Either<BuildError, Directory>> getContentDirectory(Config config) async {
  final directory = fs.directory(config.build.contentDir);
  if (await directory.exists()) {
    return Right(directory);
  } else {
    return Left(BuildError('Directory ${directory.path} does not exists'));
  }
}