Skip to content

Commit

Permalink
🐛 fixes #13 Error for 2.0x and 3.0x directories.
Browse files Browse the repository at this point in the history
Signed-off-by: birjuvachhani <[email protected]>
  • Loading branch information
BirjuVachhani committed Mar 1, 2020
1 parent d078d17 commit fb02304
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions lib/spider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Spider {
if (groups == null) {
exit_with('No groups found in config file.');
}
validateGroups();
for (var group in groups) {
var generator = DartClassGenerator(group);
generator.generate(
Expand All @@ -63,4 +64,23 @@ class Spider {
exit_with('Unable to create config file', e.stackTrace);
}
}

/// performs validation checks on provided group configurations
void validateGroups() {
for (final group in groups) {
if (group.path.isEmpty) {
exit_with('Exmpty paths are not allowed');
}
if (File(group.path).existsSync()) {
exit_with('Path ${group.path} is not a directory');
}
if (!Directory(group.path).existsSync()) {
exit_with('Path ${group.path} does not exist!');
}
final dirName = path.basename(group.path);
if (RegExp(r'^2.0x|3.0x$').hasMatch(dirName)) {
exit_with('${group.path} is not a valid asset directory.');
}
}
}
}
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: spider
description: A small dart command-line tool for generating dart references of assets from the assets folder.
version: 0.3.5
version: 0.3.6
homepage: https://github.com/BirjuVachhani/spider

environment:
Expand All @@ -9,7 +9,7 @@ environment:
dependencies:
path: ^1.6.4
yaml: ^2.2.0
args: ^1.5.2
args: ^1.5.3
dart_style: ^1.3.3
logging: ^0.11.4
watcher: ^0.9.7+13
Expand Down

0 comments on commit fb02304

Please sign in to comment.