Skip to content

Commit f689c8f

Browse files
Usage example
1 parent b7974a7 commit f689c8f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

dev/dart_quality_checks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash -ex
22

3+
dart example/main.dart
34
dartanalyzer --fatal-hints .
45
pub run test
56
pub run dependency_validator --ignore=functional_data_generator,sum_types_generator,test_coverage

example/main.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'dart:io';
2+
3+
import 'package:pubspec_yaml/pubspec_yaml.dart';
4+
5+
// ignore_for_file: avoid_print
6+
7+
void main() {
8+
final pubspecYamlContent = File('pubspec.yaml').readAsStringSync();
9+
final pubspecYaml = PubspecYaml.loadFromYamlString(pubspecYamlContent);
10+
11+
final productionOverrides = pubspecYaml.dependencyOverrides.where(
12+
(override) => pubspecYaml.dependencies.any((
13+
productionDependency,
14+
) =>
15+
productionDependency.package() == override.package()),
16+
);
17+
18+
if (productionOverrides.isEmpty) {
19+
print('SUCCESS: No overrides of production dependencies detected');
20+
} else {
21+
print('WARNING: Overrides of production dependencies detected:');
22+
productionOverrides.forEach(print);
23+
}
24+
}

example/pubspec.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: example
2+
publish_to: none
3+
4+
environment:
5+
sdk: ">=2.5.0 <3.0.0"
6+
7+
dependencies:
8+
pubspec_yaml:
9+
path: ..

0 commit comments

Comments
 (0)