Skip to content

Commit ce4b584

Browse files
authored
Patch internal cases, bump. (#191)
1 parent fbd6003 commit ce4b584

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.5.10
2+
3+
* Bug fixes:
4+
* Do not fail when "library" is omitted but nothing would be output.
5+
* Do not fail on extensions that don't end in ".dart" (valid use case).
6+
17
## 0.5.9
28

39
* Update the minimum Dart SDK to `1.22.1`.

lib/src/builder.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ class GeneratorBuilder extends Builder {
6060
if (generatedExtension == null) {
6161
throw new ArgumentError.notNull('generatedExtension');
6262
}
63-
if (generatedExtension.isEmpty ||
64-
!generatedExtension.startsWith('.') ||
65-
!generatedExtension.endsWith('.dart')) {
63+
if (generatedExtension.isEmpty || !generatedExtension.startsWith('.')) {
6664
throw new ArgumentError.value(generatedExtension, 'generatedExtension',
67-
'Extension must be in the format of .dart or .*.dart');
65+
'Extension must be in the format of .*');
6866
}
6967
if (this.isStandalone && this.generators.length > 1) {
7068
throw new ArgumentError(
@@ -94,8 +92,14 @@ class GeneratorBuilder extends Builder {
9492
var generatedOutputs =
9593
await _generate(library, generators, buildStep).toList();
9694

97-
var contentBuffer = new StringBuffer();
95+
// Don't output useless files.
96+
//
97+
// NOTE: It is important to do this check _before_ checking for valid
98+
// library/part definitions because users expect some files to be skipped
99+
// therefore they do not have "library".
100+
if (generatedOutputs.isEmpty) return;
98101

102+
var contentBuffer = new StringBuffer();
99103
if (!isStandalone) {
100104
var asset = buildStep.inputId;
101105
var name = nameOfPartial(
@@ -115,9 +119,6 @@ class GeneratorBuilder extends Builder {
115119
contentBuffer.writeln();
116120
}
117121

118-
// Don't output useless files.
119-
if (generatedOutputs.isEmpty) return;
120-
121122
for (GeneratedOutput output in generatedOutputs) {
122123
contentBuffer.writeln('');
123124
contentBuffer.writeln(_headerLine);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_gen
2-
version: 0.5.10-dev
2+
version: 0.5.10
33
author: Dart Team <[email protected]>
44
description: Automated source code generation for Dart.
55
homepage: https://github.com/dart-lang/source_gen

0 commit comments

Comments
 (0)