Skip to content

Commit b689183

Browse files
authored
Fix pre-existing output deletion. (#4058)
1 parent 1604cce commit b689183

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

build_runner/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Bug fix: fix corner case with checked in generated output that could cause
44
a crash.
5+
- Bug fix: during initial build cleanup, really delete files that correspond
6+
to hidden generated files.
57

68
## 2.5.2
79

build_runner_core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Bug fix: fix corner case with checked in generated output that could cause
44
a crash.
5+
- Bug fix: during initial build cleanup, really delete files that correspond
6+
to hidden generated files.
57

68
## 9.1.0
79

build_runner_core/lib/src/generate/build_definition.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import 'dart:io';
77

88
import 'package:build/build.dart';
99
// ignore: implementation_imports
10-
import 'package:build/src/internal.dart';
11-
// ignore: implementation_imports
1210
import 'package:build_runner/src/internal.dart';
1311
import 'package:watcher/watcher.dart';
1412

@@ -167,10 +165,10 @@ class _Loader {
167165
}
168166

169167
buildLog.doing('Doing initial build cleanup.');
170-
await _initialBuildCleanup(
171-
conflictingOutputs,
172-
_environment.writer.copyWith(generatedAssetHider: assetGraph),
173-
);
168+
// Use a writer with no asset graph. If it had the asset graph, it would
169+
// delete from the generated output location, but the aim is to delete
170+
// from input sources.
171+
await _initialBuildCleanup(conflictingOutputs, _environment.writer);
174172
}
175173

176174
return BuildDefinition._(

build_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
build: ^2.5.0
1313
build_config: ^1.0.0
1414
build_resolvers: ^2.5.0
15-
build_runner_core: ^9.1.0
15+
build_runner_core: ^9.1.1-wip
1616
convert: ^3.0.0
1717
crypto: ^3.0.0
1818
glob: ^2.0.0

build_test/test/test_builder_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,18 @@ Future<void> main() async {
344344
{AssetId('a', 'bar.other')},
345345
);
346346
});
347+
348+
test('pre-existing output is replaced by new generated output', () {
349+
return testBuilder(
350+
TestBuilder(
351+
buildExtensions: {
352+
'.in': ['.out'],
353+
},
354+
),
355+
{'a|foo.in': 'new input', 'a|foo.out': 'pre-existing output'},
356+
outputs: {'a|foo.out': 'new input'},
357+
);
358+
});
347359
}
348360

349361
/// Concatenates the contents of multiple text files into a single output.

0 commit comments

Comments
 (0)