getTargetDirectory method
Determines the target directory for generation
Implementation
@override
Future<Directory> getTargetDirectory() async {
// Determine the base directory (feature directory, custom output directory, or current directory)
final Directory baseDir;
if (outputDirectory != null) {
// Use specified output directory
baseDir = Directory(outputDirectory!);
if (!baseDir.existsSync()) {
logger.err('Output directory not found: ${baseDir.path}');
throw Exception('Output directory not found: ${baseDir.path}');
}
} else if (featureName != null) {
// Use feature directory if feature name is provided
baseDir = Directory(
path.join('features', featureName!, 'feature_$featureName'));
if (!baseDir.existsSync()) {
logger.err('Feature directory not found: ${baseDir.path}');
throw Exception('Feature directory not found: ${baseDir.path}');
}
} else {
// Default to current directory if neither output directory nor feature name is provided
baseDir = Directory('.');
logger.info(
'No feature or output directory specified. Using current directory.');
}
final contentDir = Directory(path.join(baseDir.path, 'lib', 'content'));
return contentDir;
}