generateProvider function
The generateItems function generates the folder structure according feature by folder pattern.
dryRun
is a dev-only boolean to generate example folders
Implementation
void generateProvider(
ArgResults argResults, {
bool dryRun = false,
}) async {
final customPath = argResults['path'] != null ? true : false;
var dir = argResults['path'] ?? 'feature';
if (dryRun) {
dir = 'example';
}
try {
final brick = Brick.git(
GitPath(
'https://github.com/bazl-E/feature_folder_structure',
path: 'bricks/provider',
),
);
final generator = await MasonGenerator.fromBrick(brick);
final target = DirectoryGeneratorTarget(
Directory(customPath
? DirectoryService.replaceAsExpected(path: 'lib/$dir')
: DirectoryService.paths[dir]!),
);
await generator.generate(
target,
vars: <String, dynamic>{'name': argResults['name'].toString()},
);
} on Exception catch (e) {
LogService.error(e.toString());
}
}