Skip to content

Commit

Permalink
DartDevRunner: workaround type failure
Browse files Browse the repository at this point in the history
Also run `ddev format` to fix wrapping in executable.dart.
  • Loading branch information
alexandercampbell-wk committed Mar 5, 2024
1 parent 924cf9d commit a400944
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion lib/src/dart_dev_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ class DartDevRunner extends CommandRunner<int> {
: super('dart_dev', 'Dart tool runner.') {
// For backwards-compatibility, only add the `clean` command if it doesn't
// conflict with any configured command.
commands.putIfAbsent('clean', () => CleanTool());
if (!commands.containsKey('clean')) {
// Construct a new commands map here, to work around a runtime typecheck
// failure:
// `type 'CleanTool' is not a subtype of type 'FormatTool' of 'value'`
// As seen in this CI run:
// https://github.com/Workiva/dart_dev/actions/runs/8161855516/job/22311519665?pr=426#step:8:295
commands = <String, DevTool>{...commands, 'clean': CleanTool()};
}

commands.forEach((name, builder) {
final command = builder.toCommand(name);
Expand Down
7 changes: 4 additions & 3 deletions lib/src/executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ List<String> generateRunScript() {
RegExp(r'''^import ['"][^:]+$''', multiLine: true).hasMatch(contents);
final currentPackageName =
Pubspec.parse(File('pubspec.yaml').readAsStringSync()).name;
configHasSamePackageImports =
RegExp('''^import ['"]package:$currentPackageName\/''', multiLine: true)
.hasMatch(contents);
configHasSamePackageImports = RegExp(
'''^import ['"]package:$currentPackageName\/''',
multiLine: true)
.hasMatch(contents);
}

if (configHasSamePackageImports) {
Expand Down

0 comments on commit a400944

Please sign in to comment.