Skip to content

Commit bdba6fb

Browse files
author
Ivan Dlugos
committed
generator - avoid "pubspec.yaml not found" log message for dirs that have no entities
1 parent a2ffc2d commit bdba6fb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

generator/lib/src/code_builder.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ class CodeBuilder extends Builder {
3030
@override
3131
FutureOr<void> build(BuildStep buildStep) async {
3232
// build() will be called only twice, once for the `lib` directory and once for the `test` directory
33-
Pubspec? pubspec;
34-
try {
35-
final pubspecFile = File(path.join(dir(buildStep), '../pubspec.yaml'));
36-
pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
37-
} catch (e) {
38-
log.info("Couldn't load pubspec.yaml: $e");
39-
}
40-
4133
// map from file name to a 'json' representation of entities
4234
final files = <String, List<dynamic>>{};
4335
final glob = Glob(dir(buildStep) + '/**' + EntityResolver.suffix);
@@ -61,6 +53,14 @@ class CodeBuilder extends Builder {
6153
// update the model JSON with the read entities
6254
final model = await updateModel(entities, buildStep);
6355

56+
Pubspec? pubspec;
57+
try {
58+
final pubspecFile = File(path.join(dir(buildStep), '../pubspec.yaml'));
59+
pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
60+
} catch (e) {
61+
log.info("Couldn't load pubspec.yaml: $e");
62+
}
63+
6464
// generate binding code
6565
updateCode(model, files.keys.toList(growable: false), buildStep, pubspec);
6666
}

0 commit comments

Comments
 (0)