@@ -10,6 +10,7 @@ import 'package:args/args.dart';
1010import 'package:args/command_runner.dart' ;
1111import 'package:cli_util/cli_logging.dart' ;
1212import 'package:dart_style/src/cli/format_command.dart' ;
13+ import 'package:meta/meta.dart' ;
1314import 'package:nnbd_migration/migration_cli.dart' ;
1415import 'package:pedantic/pedantic.dart' ;
1516import 'package:pub/pub.dart' ;
@@ -112,22 +113,30 @@ class DartdevRunner extends CommandRunner<int> {
112113 String get invocation =>
113114 'dart [<vm-flags>] <command|dart-file> [<arguments>]' ;
114115
116+ @visibleForTesting
117+ Analytics get analytics => _analytics;
118+ Analytics _analytics;
119+
115120 @override
116121 Future <int > runCommand (ArgResults topLevelResults) async {
117122 final stopwatch = Stopwatch ()..start ();
118123 // The Analytics instance used to report information back to Google Analytics;
119124 // see lib/src/analytics.dart.
120- final analytics = createAnalyticsInstance (! topLevelResults['analytics' ]);
125+ _analytics = createAnalyticsInstance (
126+ topLevelResults.wasParsed ('analytics' )
127+ ? ! topLevelResults['analytics' ]
128+ : false ,
129+ );
121130
122131 // If we have not printed the analyticsNoticeOnFirstRunMessage to stdout,
123132 // the user is on a terminal, and the machine is not a bot, then print the
124133 // disclosure and set analytics.disclosureShownOnTerminal to true.
125134 if (analytics is DartdevAnalytics &&
126- ! analytics.disclosureShownOnTerminal &&
135+ ! ( analytics as DartdevAnalytics ) .disclosureShownOnTerminal &&
127136 io.stdout.hasTerminal &&
128137 ! isBot ()) {
129138 print (analyticsNoticeOnFirstRunMessage);
130- analytics.disclosureShownOnTerminal = true ;
139+ ( analytics as DartdevAnalytics ) .disclosureShownOnTerminal = true ;
131140 }
132141
133142 // When `--disable-analytics` or `--enable-analytics` are called we perform
0 commit comments