Skip to content

Commit cc81445

Browse files
committed
Allow an option called run_only_if_triggered.
1 parent b7fd5fc commit cc81445

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

json_serializable/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.12.0-wip
2+
3+
- Allow an option called `run_only_if_triggered` so it can be used by
4+
`build_runner`.
5+
16
## 6.11.1
27

38
- Allow `build: '>=3.0.0 <5.0.0'`.

json_serializable/lib/builder.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ import 'src/json_part_builder.dart';
2323
/// Not meant to be invoked by hand-authored code.
2424
Builder jsonSerializable(BuilderOptions options) {
2525
try {
26-
final config = JsonSerializable.fromJson(options.config);
26+
var configJson = options.config;
27+
// Ignore `run_only_if_triggered` if present, it's used by `build_runner`.
28+
if (configJson.containsKey('run_only_if_triggered')) {
29+
configJson = Map.of(configJson)..remove('run_only_if_triggered');
30+
}
31+
final config = JsonSerializable.fromJson(configJson);
2732
return jsonPartBuilder(config: config);
2833
} on CheckedFromJsonException catch (e) {
2934
final lines = <String>[

0 commit comments

Comments
 (0)