Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions bin/assetlib.dart → bin/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class Generator with AssetClass {

/// Initialize the generator.
/// - [results] - The command-line arguments.
init() {
init() async {
final className = results?['class'] ?? defaultClassName;

final filePath = results?['output'] ?? defaultOutput;

if (FileSystemEntity.isDirectorySync(filePath)) {
stdout.writeln('Generating $className in $filePath...');
} else {
stdout.writeln('The output path is not a directory.');
stdout.writeln('Run `assetlib --help` for more information.');
stdout.writeln('[INFO] The output path is not a directory.');
stdout.writeln('[INFO] Run `assetlib --help` for more information.');
exit(1);
}

Expand Down Expand Up @@ -75,13 +75,15 @@ class Generator with AssetClass {

sink.writeln('}');
sink.close();

stdout.writeln('[INFO] Formatting assets file');
await Process.run("dart", ["format"]);
}

final List<String> _writtenAssets = [];

_writeAssetsFromDirectory(Directory directory, IOSink sink) {
final List<FileSystemEntity> entities =
directory.listSync().skipWhile((entity) {
final entities = directory.listSync().skipWhile((entity) {
return FileSystemEntity.isDirectorySync(entity.path);
}).toList();

Expand All @@ -91,7 +93,8 @@ class Generator with AssetClass {
}

stdout.writeln(
'Found ${entities.length} file${entities.length > 1 ? 's' : ''} in ${directory.path}');
'Found ${entities.length} file${entities.length > 1 ? 's' : ''} in ${directory.path}',
);

for (var entity in entities) {
stdout.writeln('');
Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ mixin AssetClass {
return word[0].toUpperCase() + word.substring(1);
}).join('');

//TODO: Minor suggestion
// final k = _pubspec['name'].toString().split("").first.toUpperCase();

return '${name}Assets';
}

Expand Down