build method
Worker method that accomplishes builder goals as described in class header
Implementation
@override
FutureOr<void> build(BuildStep buildStep) async {
log.fine('Starting build w/ buildStep ${buildStep}');
String microPackagesCurrentFolder =
path.join(Directory.current.path,
microPackagesRootFolder
);
if (!await Directory(microPackagesCurrentFolder).exists()) {
//if the folder doesn't exist we are not supporting micropackages or maybe we are inside one... just leave
return;
}
var featureUriSet = await Future.wait(
await Directory(microPackagesCurrentFolder)
.list(recursive: true)
.where((file) =>
_getExtension(file.path, dept: 2) == 'micropackage.json')
.map((file) async => await _toMicroPackageModuleModel(file))
.toSet());
log.fine(
"Found ${featureUriSet.length} micro packages with micropackage.json file");
return await buildStep.writeAsString(
AssetId(buildStep.inputId.package, path.join('lib',generatedOutputFileName)),
jsonEncode(featureUriSet));
}