Migrator: use pub.bat on Windows
Fixes https://github.com/dart-lang/sdk/issues/42102
Change-Id: Ic2dd785a84835402c7af3ef7b8d15285585a0afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149386
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
diff --git a/pkg/nnbd_migration/lib/migration_cli.dart b/pkg/nnbd_migration/lib/migration_cli.dart
index fac97be..360b112 100644
--- a/pkg/nnbd_migration/lib/migration_cli.dart
+++ b/pkg/nnbd_migration/lib/migration_cli.dart
@@ -81,6 +81,7 @@
@visibleForTesting
class DependencyChecker {
+ static final _pubName = Platform.isWindows ? 'pub.bat' : 'pub';
final Context _pathContext;
final Logger _logger;
final ProcessManager _processManager;
@@ -88,7 +89,7 @@
DependencyChecker(this._pathContext, this._logger, this._processManager);
bool check() {
- var pubPath = _pathContext.join(getSdkPath(), 'bin', 'pub');
+ var pubPath = _pathContext.join(getSdkPath(), 'bin', _pubName);
var result = _processManager
.runSync(pubPath, ['outdated', '--mode=null-safety', '--json']);
@@ -96,7 +97,7 @@
try {
if ((result.stderr as String).isNotEmpty) {
throw FormatException(
- '`pub outdated --mode=null-safety` exited with exit code '
+ '`$_pubName outdated --mode=null-safety` exited with exit code '
'${result.exitCode} and stderr:\n\n${result.stderr}');
}
var outdatedOutput = jsonDecode(result.stdout as String);
@@ -141,8 +142,8 @@
}
_logger.stderr('');
_logger.stderr('It is highly recommended to upgrade all dependencies to '
- 'versions which have migrated. Use `pub outdated --mode=null-safety` '
- 'to check the status of dependencies. Visit '
+ 'versions which have migrated. Use `$_pubName outdated '
+ '--mode=null-safety` to check the status of dependencies. Visit '
'https://dart.dev/tools/pub/cmd/pub-outdated for more information.');
_logger.stderr('');
_logger.stderr('Force migration with --skip-outdated-dependencies-check '
@@ -157,7 +158,7 @@
return map[key];
}
throw FormatException(
- 'Unexpected `pub outdated` JSON output: missing key ($key)', map);
+ 'Unexpected `$_pubName outdated` JSON output: missing key ($key)', map);
}
T _expectType<T>(Object object, String errorKey) {
@@ -165,7 +166,7 @@
return object;
}
throw FormatException(
- 'Unexpected `pub outdated` JSON output: expected a '
+ 'Unexpected `$_pubName outdated` JSON output: expected a '
'$T at "$errorKey", but got a ${object.runtimeType}',
object);
}