Unverified Commit ba57ea09 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Revert "Move processUtils into globals (#53209)" (#53301)

parent 86389be6
...@@ -225,7 +225,7 @@ class AndroidDevice extends Device { ...@@ -225,7 +225,7 @@ class AndroidDevice extends Device {
bool allowReentrantFlutter = false, bool allowReentrantFlutter = false,
Map<String, String> environment, Map<String, String> environment,
}) { }) {
return globals.processUtils.runSync( return processUtils.runSync(
adbCommandForDevice(params), adbCommandForDevice(params),
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
...@@ -240,7 +240,7 @@ class AndroidDevice extends Device { ...@@ -240,7 +240,7 @@ class AndroidDevice extends Device {
String workingDirectory, String workingDirectory,
bool allowReentrantFlutter = false, bool allowReentrantFlutter = false,
}) async { }) async {
return globals.processUtils.run( return processUtils.run(
adbCommandForDevice(params), adbCommandForDevice(params),
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
...@@ -278,7 +278,7 @@ class AndroidDevice extends Device { ...@@ -278,7 +278,7 @@ class AndroidDevice extends Device {
} }
try { try {
final RunResult adbVersion = await globals.processUtils.run( final RunResult adbVersion = await processUtils.run(
<String>[getAdbPath(androidSdk), 'version'], <String>[getAdbPath(androidSdk), 'version'],
throwOnError: true, throwOnError: true,
); );
...@@ -299,7 +299,7 @@ class AndroidDevice extends Device { ...@@ -299,7 +299,7 @@ class AndroidDevice extends Device {
// output lines like this, which we want to ignore: // output lines like this, which we want to ignore:
// adb server is out of date. killing.. // adb server is out of date. killing..
// * daemon started successfully * // * daemon started successfully *
await globals.processUtils.run( await processUtils.run(
<String>[getAdbPath(androidSdk), 'start-server'], <String>[getAdbPath(androidSdk), 'start-server'],
throwOnError: true, throwOnError: true,
); );
...@@ -336,7 +336,7 @@ class AndroidDevice extends Device { ...@@ -336,7 +336,7 @@ class AndroidDevice extends Device {
} }
Future<String> _getDeviceApkSha1(AndroidApk apk) async { Future<String> _getDeviceApkSha1(AndroidApk apk) async {
final RunResult result = await globals.processUtils.run( final RunResult result = await processUtils.run(
adbCommandForDevice(<String>['shell', 'cat', _getDeviceSha1Path(apk)])); adbCommandForDevice(<String>['shell', 'cat', _getDeviceSha1Path(apk)]));
return result.stdout; return result.stdout;
} }
...@@ -380,7 +380,7 @@ class AndroidDevice extends Device { ...@@ -380,7 +380,7 @@ class AndroidDevice extends Device {
} }
final Status status = globals.logger.startProgress('Installing ${globals.fs.path.relative(app.file.path)}...', timeout: timeoutConfiguration.slowOperation); final Status status = globals.logger.startProgress('Installing ${globals.fs.path.relative(app.file.path)}...', timeout: timeoutConfiguration.slowOperation);
final RunResult installResult = await globals.processUtils.run( final RunResult installResult = await processUtils.run(
adbCommandForDevice(<String>['install', '-t', '-r', app.file.path])); adbCommandForDevice(<String>['install', '-t', '-r', app.file.path]));
status.stop(); status.stop();
// Some versions of adb exit with exit code 0 even on failure :( // Some versions of adb exit with exit code 0 even on failure :(
...@@ -416,7 +416,7 @@ class AndroidDevice extends Device { ...@@ -416,7 +416,7 @@ class AndroidDevice extends Device {
String uninstallOut; String uninstallOut;
try { try {
final RunResult uninstallResult = await globals.processUtils.run( final RunResult uninstallResult = await processUtils.run(
adbCommandForDevice(<String>['uninstall', app.id]), adbCommandForDevice(<String>['uninstall', app.id]),
throwOnError: true, throwOnError: true,
); );
...@@ -647,13 +647,13 @@ class AndroidDevice extends Device { ...@@ -647,13 +647,13 @@ class AndroidDevice extends Device {
@override @override
Future<bool> stopApp(AndroidApk app) { Future<bool> stopApp(AndroidApk app) {
final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]); final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]);
return globals.processUtils.stream(command).then<bool>( return processUtils.stream(command).then<bool>(
(int exitCode) => exitCode == 0 || allowHeapCorruptionOnWindows(exitCode)); (int exitCode) => exitCode == 0 || allowHeapCorruptionOnWindows(exitCode));
} }
@override @override
Future<MemoryInfo> queryMemoryInfo() async { Future<MemoryInfo> queryMemoryInfo() async {
final RunResult runResult = await globals.processUtils.run(adbCommandForDevice(<String>[ final RunResult runResult = await processUtils.run(adbCommandForDevice(<String>[
'shell', 'shell',
'dumpsys', 'dumpsys',
'meminfo', 'meminfo',
...@@ -669,7 +669,7 @@ class AndroidDevice extends Device { ...@@ -669,7 +669,7 @@ class AndroidDevice extends Device {
@override @override
void clearLogs() { void clearLogs() {
globals.processUtils.runSync(adbCommandForDevice(<String>['logcat', '-c'])); processUtils.runSync(adbCommandForDevice(<String>['logcat', '-c']));
} }
@override @override
...@@ -709,7 +709,7 @@ class AndroidDevice extends Device { ...@@ -709,7 +709,7 @@ class AndroidDevice extends Device {
Future<void> takeScreenshot(File outputFile) async { Future<void> takeScreenshot(File outputFile) async {
const String remotePath = '/data/local/tmp/flutter_screenshot.png'; const String remotePath = '/data/local/tmp/flutter_screenshot.png';
await runAdbCheckedAsync(<String>['shell', 'screencap', '-p', remotePath]); await runAdbCheckedAsync(<String>['shell', 'screencap', '-p', remotePath]);
await globals.processUtils.run( await processUtils.run(
adbCommandForDevice(<String>['pull', remotePath, outputFile.path]), adbCommandForDevice(<String>['pull', remotePath, outputFile.path]),
throwOnError: true, throwOnError: true,
); );
...@@ -1074,7 +1074,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder { ...@@ -1074,7 +1074,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
String stdout; String stdout;
try { try {
stdout = globals.processUtils.runSync( stdout = processUtils.runSync(
device.adbCommandForDevice(<String>['forward', '--list']), device.adbCommandForDevice(<String>['forward', '--list']),
throwOnError: true, throwOnError: true,
).stdout.trim(); ).stdout.trim();
...@@ -1118,7 +1118,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder { ...@@ -1118,7 +1118,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
'tcp:$hostPort', 'tcp:$hostPort',
'tcp:$devicePort', 'tcp:$devicePort',
]; ];
final RunResult process = await globals.processUtils.run( final RunResult process = await processUtils.run(
device.adbCommandForDevice(forwardCommand), device.adbCommandForDevice(forwardCommand),
throwOnError: true, throwOnError: true,
); );
...@@ -1171,7 +1171,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder { ...@@ -1171,7 +1171,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder {
'--remove', '--remove',
'tcp:${forwardedPort.hostPort}', 'tcp:${forwardedPort.hostPort}',
]; ];
await globals.processUtils.run( await processUtils.run(
device.adbCommandForDevice(unforwardCommand), device.adbCommandForDevice(unforwardCommand),
throwOnError: true, throwOnError: true,
); );
......
...@@ -11,6 +11,7 @@ import '../android/android_workflow.dart'; ...@@ -11,6 +11,7 @@ import '../android/android_workflow.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/process.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../convert.dart'; import '../convert.dart';
import '../device.dart'; import '../device.dart';
...@@ -53,7 +54,7 @@ class AndroidEmulator extends Emulator { ...@@ -53,7 +54,7 @@ class AndroidEmulator extends Emulator {
@override @override
Future<void> launch() async { Future<void> launch() async {
final Process process = await globals.processUtils.start( final Process process = await processUtils.start(
<String>[getEmulatorPath(androidSdk), '-avd', id], <String>[getEmulatorPath(androidSdk), '-avd', id],
); );
...@@ -116,7 +117,7 @@ List<AndroidEmulator> getEmulatorAvds() { ...@@ -116,7 +117,7 @@ List<AndroidEmulator> getEmulatorAvds() {
return <AndroidEmulator>[]; return <AndroidEmulator>[];
} }
final String listAvdsOutput = globals.processUtils.runSync( final String listAvdsOutput = processUtils.runSync(
<String>[emulatorPath, '-list-avds']).stdout.trim(); <String>[emulatorPath, '-list-avds']).stdout.trim();
final List<AndroidEmulator> emulators = <AndroidEmulator>[]; final List<AndroidEmulator> emulators = <AndroidEmulator>[];
......
...@@ -582,7 +582,7 @@ class AndroidSdk { ...@@ -582,7 +582,7 @@ class AndroidSdk {
// See: http://stackoverflow.com/questions/14292698/how-do-i-check-if-the-java-jdk-is-installed-on-mac. // See: http://stackoverflow.com/questions/14292698/how-do-i-check-if-the-java-jdk-is-installed-on-mac.
if (platform.isMacOS) { if (platform.isMacOS) {
try { try {
final String javaHomeOutput = globals.processUtils.runSync( final String javaHomeOutput = processUtils.runSync(
<String>['/usr/libexec/java_home'], <String>['/usr/libexec/java_home'],
throwOnError: true, throwOnError: true,
hideStdout: true, hideStdout: true,
...@@ -628,7 +628,7 @@ class AndroidSdk { ...@@ -628,7 +628,7 @@ class AndroidSdk {
if (!globals.processManager.canRun(sdkManagerPath)) { if (!globals.processManager.canRun(sdkManagerPath)) {
throwToolExit('Android sdkmanager not found. Update to the latest Android SDK to resolve this.'); throwToolExit('Android sdkmanager not found. Update to the latest Android SDK to resolve this.');
} }
final RunResult result = globals.processUtils.runSync( final RunResult result = processUtils.runSync(
<String>[sdkManagerPath, '--version'], <String>[sdkManagerPath, '--version'],
environment: sdkManagerEnv, environment: sdkManagerEnv,
); );
......
...@@ -310,7 +310,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -310,7 +310,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
} else { } else {
RunResult result; RunResult result;
try { try {
result = globals.processUtils.runSync(<String>[javaExecutable, '-version']); result = processUtils.runSync(<String>[javaExecutable, '-version']);
} on ProcessException catch (e) { } on ProcessException catch (e) {
_validationMessages.add('Failed to run Java: $e'); _validationMessages.add('Failed to run Java: $e');
} }
......
...@@ -14,6 +14,7 @@ import '../base/file_system.dart'; ...@@ -14,6 +14,7 @@ import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/process.dart';
import '../base/user_messages.dart'; import '../base/user_messages.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../base/version.dart'; import '../base/version.dart';
...@@ -322,7 +323,7 @@ class AndroidLicenseValidator extends DoctorValidator { ...@@ -322,7 +323,7 @@ class AndroidLicenseValidator extends DoctorValidator {
} }
try { try {
final Process process = await globals.processUtils.start( final Process process = await processUtils.start(
<String>[androidSdk.sdkManagerPath, '--licenses'], <String>[androidSdk.sdkManagerPath, '--licenses'],
environment: androidSdk.sdkManagerEnv, environment: androidSdk.sdkManagerEnv,
); );
...@@ -359,7 +360,7 @@ class AndroidLicenseValidator extends DoctorValidator { ...@@ -359,7 +360,7 @@ class AndroidLicenseValidator extends DoctorValidator {
} }
try { try {
final Process process = await globals.processUtils.start( final Process process = await processUtils.start(
<String>[androidSdk.sdkManagerPath, '--licenses'], <String>[androidSdk.sdkManagerPath, '--licenses'],
environment: androidSdk.sdkManagerEnv, environment: androidSdk.sdkManagerEnv,
); );
......
...@@ -142,7 +142,7 @@ Future<void> checkGradleDependencies() async { ...@@ -142,7 +142,7 @@ Future<void> checkGradleDependencies() async {
timeout: timeoutConfiguration.slowOperation, timeout: timeoutConfiguration.slowOperation,
); );
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
await globals.processUtils.run(<String>[ await processUtils.run(<String>[
gradleUtils.getExecutable(flutterProject), gradleUtils.getExecutable(flutterProject),
'dependencies', 'dependencies',
], ],
...@@ -382,7 +382,7 @@ Future<void> buildGradleApp({ ...@@ -382,7 +382,7 @@ Future<void> buildGradleApp({
final Stopwatch sw = Stopwatch()..start(); final Stopwatch sw = Stopwatch()..start();
int exitCode = 1; int exitCode = 1;
try { try {
exitCode = await globals.processUtils.stream( exitCode = await processUtils.stream(
command, command,
workingDirectory: project.android.hostAppGradleRoot.path, workingDirectory: project.android.hostAppGradleRoot.path,
allowReentrantFlutter: true, allowReentrantFlutter: true,
...@@ -584,7 +584,7 @@ Future<void> buildGradleAar({ ...@@ -584,7 +584,7 @@ Future<void> buildGradleAar({
final Stopwatch sw = Stopwatch()..start(); final Stopwatch sw = Stopwatch()..start();
RunResult result; RunResult result;
try { try {
result = await globals.processUtils.run( result = await processUtils.run(
command, command,
workingDirectory: project.android.hostAppGradleRoot.path, workingDirectory: project.android.hostAppGradleRoot.path,
allowReentrantFlutter: true, allowReentrantFlutter: true,
......
...@@ -270,7 +270,7 @@ final GradleHandledError flavorUndefinedHandler = GradleHandledError( ...@@ -270,7 +270,7 @@ final GradleHandledError flavorUndefinedHandler = GradleHandledError(
bool usesAndroidX, bool usesAndroidX,
bool shouldBuildPluginAsAar, bool shouldBuildPluginAsAar,
}) async { }) async {
final RunResult tasksRunResult = await globals.processUtils.run( final RunResult tasksRunResult = await processUtils.run(
<String>[ <String>[
gradleUtils.getExecutable(project), gradleUtils.getExecutable(project),
'app:tasks' , 'app:tasks' ,
......
...@@ -117,7 +117,7 @@ class AndroidApk extends ApplicationPackage { ...@@ -117,7 +117,7 @@ class AndroidApk extends ApplicationPackage {
String apptStdout; String apptStdout;
try { try {
apptStdout = globals.processUtils.runSync( apptStdout = processUtils.runSync(
<String>[ <String>[
aaptPath, aaptPath,
'dump', 'dump',
......
...@@ -180,6 +180,8 @@ class RunResult { ...@@ -180,6 +180,8 @@ class RunResult {
typedef RunResultChecker = bool Function(int); typedef RunResultChecker = bool Function(int);
ProcessUtils get processUtils => ProcessUtils.instance;
abstract class ProcessUtils { abstract class ProcessUtils {
factory ProcessUtils({ factory ProcessUtils({
@required ProcessManager processManager, @required ProcessManager processManager,
...@@ -189,6 +191,8 @@ abstract class ProcessUtils { ...@@ -189,6 +191,8 @@ abstract class ProcessUtils {
logger: logger, logger: logger,
); );
static ProcessUtils get instance => context.get<ProcessUtils>();
/// Spawns a child process to run the command [cmd]. /// Spawns a child process to run the command [cmd].
/// ///
/// When [throwOnError] is `true`, if the child process finishes with a non-zero /// When [throwOnError] is `true`, if the child process finishes with a non-zero
......
...@@ -224,7 +224,7 @@ class DebugUniveralFramework extends Target { ...@@ -224,7 +224,7 @@ class DebugUniveralFramework extends Target {
'-output', '-output',
lipoOutputFile.path lipoOutputFile.path
]; ];
final RunResult lipoResult = await globals.processUtils.run( final RunResult lipoResult = await processUtils.run(
lipoCommand, lipoCommand,
); );
......
...@@ -984,7 +984,7 @@ class AndroidMavenArtifacts extends ArtifactSet { ...@@ -984,7 +984,7 @@ class AndroidMavenArtifacts extends ArtifactSet {
try { try {
final String gradleExecutable = gradle.absolute.path; final String gradleExecutable = gradle.absolute.path;
final String flutterSdk = globals.fsUtils.escapePath(Cache.flutterRoot); final String flutterSdk = globals.fsUtils.escapePath(Cache.flutterRoot);
final RunResult processResult = await globals.processUtils.run( final RunResult processResult = await processUtils.run(
<String>[ <String>[
gradleExecutable, gradleExecutable,
'-b', globals.fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'), '-b', globals.fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'),
......
...@@ -324,7 +324,7 @@ end ...@@ -324,7 +324,7 @@ end
'-output', '-output',
fatFlutterFrameworkBinary.path fatFlutterFrameworkBinary.path
]; ];
final RunResult lipoResult = await globals.processUtils.run( final RunResult lipoResult = await processUtils.run(
lipoCommand, lipoCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
...@@ -406,7 +406,7 @@ end ...@@ -406,7 +406,7 @@ end
destinationAppFrameworkDirectory.childFile(binaryName).path destinationAppFrameworkDirectory.childFile(binaryName).path
]; ];
final RunResult lipoResult = await globals.processUtils.run( final RunResult lipoResult = await processUtils.run(
lipoCommand, lipoCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
...@@ -478,7 +478,7 @@ end ...@@ -478,7 +478,7 @@ end
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
]; ];
RunResult buildPluginsResult = await globals.processUtils.run( RunResult buildPluginsResult = await processUtils.run(
pluginsBuildCommand, pluginsBuildCommand,
workingDirectory: _project.ios.hostAppRoot.childDirectory('Pods').path, workingDirectory: _project.ios.hostAppRoot.childDirectory('Pods').path,
allowReentrantFlutter: false, allowReentrantFlutter: false,
...@@ -504,7 +504,7 @@ end ...@@ -504,7 +504,7 @@ end
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
]; ];
buildPluginsResult = await globals.processUtils.run( buildPluginsResult = await processUtils.run(
pluginsBuildCommand, pluginsBuildCommand,
workingDirectory: _project.ios.hostAppRoot workingDirectory: _project.ios.hostAppRoot
.childDirectory('Pods') .childDirectory('Pods')
...@@ -556,7 +556,7 @@ end ...@@ -556,7 +556,7 @@ end
modeDirectory.childDirectory(podFrameworkName).childFile(binaryName).path modeDirectory.childDirectory(podFrameworkName).childFile(binaryName).path
]; ];
final RunResult pluginsLipoResult = await globals.processUtils.run( final RunResult pluginsLipoResult = await processUtils.run(
lipoCommand, lipoCommand,
workingDirectory: outputDirectory.path, workingDirectory: outputDirectory.path,
allowReentrantFlutter: false, allowReentrantFlutter: false,
...@@ -587,7 +587,7 @@ end ...@@ -587,7 +587,7 @@ end
modeDirectory.childFile('$binaryName.xcframework').path modeDirectory.childFile('$binaryName.xcframework').path
]; ];
final RunResult xcframeworkResult = await globals.processUtils.run( final RunResult xcframeworkResult = await processUtils.run(
xcframeworkCommand, xcframeworkCommand,
workingDirectory: outputDirectory.path, workingDirectory: outputDirectory.path,
allowReentrantFlutter: false, allowReentrantFlutter: false,
...@@ -664,7 +664,7 @@ end ...@@ -664,7 +664,7 @@ end
armFlutterFrameworkBinary.path armFlutterFrameworkBinary.path
]; ];
RunResult lipoResult = await globals.processUtils.run( RunResult lipoResult = await processUtils.run(
lipoCommand, lipoCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
...@@ -690,7 +690,7 @@ end ...@@ -690,7 +690,7 @@ end
simulatorFlutterFrameworkBinary.path simulatorFlutterFrameworkBinary.path
]; ];
lipoResult = await globals.processUtils.run( lipoResult = await processUtils.run(
lipoCommand, lipoCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
...@@ -712,7 +712,7 @@ end ...@@ -712,7 +712,7 @@ end
.path .path
]; ];
final RunResult xcframeworkResult = await globals.processUtils.run( final RunResult xcframeworkResult = await processUtils.run(
xcframeworkCommand, xcframeworkCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
...@@ -744,7 +744,7 @@ end ...@@ -744,7 +744,7 @@ end
.path .path
]; ];
final RunResult xcframeworkResult = await globals.processUtils.run( final RunResult xcframeworkResult = await processUtils.run(
xcframeworkCommand, xcframeworkCommand,
allowReentrantFlutter: false, allowReentrantFlutter: false,
); );
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:async'; import 'dart:async';
import '../base/common.dart'; import '../base/common.dart';
import '../base/process.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -60,7 +61,7 @@ class ChannelCommand extends FlutterCommand { ...@@ -60,7 +61,7 @@ class ChannelCommand extends FlutterCommand {
showAll = showAll || currentChannel != currentBranch; showAll = showAll || currentChannel != currentBranch;
globals.printStatus('Flutter channels:'); globals.printStatus('Flutter channels:');
final int result = await globals.processUtils.stream( final int result = await processUtils.stream(
<String>['git', 'branch', '-r'], <String>['git', 'branch', '-r'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
mapFunction: (String line) { mapFunction: (String line) {
...@@ -139,28 +140,28 @@ class ChannelCommand extends FlutterCommand { ...@@ -139,28 +140,28 @@ class ChannelCommand extends FlutterCommand {
static Future<void> _checkout(String branchName) async { static Future<void> _checkout(String branchName) async {
// Get latest refs from upstream. // Get latest refs from upstream.
int result = await globals.processUtils.stream( int result = await processUtils.stream(
<String>['git', 'fetch'], <String>['git', 'fetch'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
prefix: 'git: ', prefix: 'git: ',
); );
if (result == 0) { if (result == 0) {
result = await globals.processUtils.stream( result = await processUtils.stream(
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'], <String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
prefix: 'git: ', prefix: 'git: ',
); );
if (result == 0) { if (result == 0) {
// branch already exists, try just switching to it // branch already exists, try just switching to it
result = await globals.processUtils.stream( result = await processUtils.stream(
<String>['git', 'checkout', branchName, '--'], <String>['git', 'checkout', branchName, '--'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
prefix: 'git: ', prefix: 'git: ',
); );
} else { } else {
// branch does not exist, we have to create it // branch does not exist, we have to create it
result = await globals.processUtils.stream( result = await processUtils.stream(
<String>['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'], <String>['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'],
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
prefix: 'git: ', prefix: 'git: ',
......
...@@ -11,6 +11,7 @@ import 'package:webdriver/async_io.dart' as async_io; ...@@ -11,6 +11,7 @@ import 'package:webdriver/async_io.dart' as async_io;
import '../application_package.dart'; import '../application_package.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/process.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
...@@ -467,7 +468,7 @@ Future<void> _runTests(List<String> testArgs, Map<String, String> environment) a ...@@ -467,7 +468,7 @@ Future<void> _runTests(List<String> testArgs, Map<String, String> environment) a
PackageMap.globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(PackageMap.globalPackagesPath)); PackageMap.globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(PackageMap.globalPackagesPath));
final String dartVmPath = globals.fs.path.join(dartSdkPath, 'bin', 'dart'); final String dartVmPath = globals.fs.path.join(dartSdkPath, 'bin', 'dart');
final int result = await globals.processUtils.stream( final int result = await processUtils.stream(
<String>[ <String>[
dartVmPath, dartVmPath,
...dartVmFlags, ...dartVmFlags,
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
import 'dart:async'; import 'dart:async';
import '../base/common.dart'; import '../base/common.dart';
import '../base/process.dart';
import '../dart/sdk.dart'; import '../dart/sdk.dart';
import '../globals.dart' as globals;
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
class FormatCommand extends FlutterCommand { class FormatCommand extends FlutterCommand {
...@@ -71,7 +71,7 @@ class FormatCommand extends FlutterCommand { ...@@ -71,7 +71,7 @@ class FormatCommand extends FlutterCommand {
...argResults.rest, ...argResults.rest,
]; ];
final int result = await globals.processUtils.stream(command); final int result = await processUtils.stream(command);
if (result != 0) { if (result != 0) {
throwToolExit('Formatting failed: $result', exitCode: result); throwToolExit('Formatting failed: $result', exitCode: result);
} }
......
...@@ -61,7 +61,7 @@ class UpgradeCommand extends FlutterCommand { ...@@ -61,7 +61,7 @@ class UpgradeCommand extends FlutterCommand {
force: boolArg('force'), force: boolArg('force'),
continueFlow: boolArg('continue'), continueFlow: boolArg('continue'),
testFlow: stringArg('working-directory') != null, testFlow: stringArg('working-directory') != null,
gitTagVersion: GitTagVersion.determine(globals.processUtils), gitTagVersion: GitTagVersion.determine(processUtils),
flutterVersion: stringArg('working-directory') == null flutterVersion: stringArg('working-directory') == null
? globals.flutterVersion ? globals.flutterVersion
: FlutterVersion(const SystemClock(), _commandRunner.workingDirectory), : FlutterVersion(const SystemClock(), _commandRunner.workingDirectory),
...@@ -152,7 +152,7 @@ class UpgradeCommandRunner { ...@@ -152,7 +152,7 @@ class UpgradeCommandRunner {
} }
Future<void> flutterUpgradeContinue() async { Future<void> flutterUpgradeContinue() async {
final int code = await globals.processUtils.stream( final int code = await processUtils.stream(
<String>[ <String>[
globals.fs.path.join('bin', 'flutter'), globals.fs.path.join('bin', 'flutter'),
'upgrade', 'upgrade',
...@@ -182,7 +182,7 @@ class UpgradeCommandRunner { ...@@ -182,7 +182,7 @@ class UpgradeCommandRunner {
Future<bool> hasUncomittedChanges() async { Future<bool> hasUncomittedChanges() async {
try { try {
final RunResult result = await globals.processUtils.run( final RunResult result = await processUtils.run(
<String>['git', 'status', '-s'], <String>['git', 'status', '-s'],
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
...@@ -205,7 +205,7 @@ class UpgradeCommandRunner { ...@@ -205,7 +205,7 @@ class UpgradeCommandRunner {
/// Exits tool if there is no upstream. /// Exits tool if there is no upstream.
Future<void> verifyUpstreamConfigured() async { Future<void> verifyUpstreamConfigured() async {
try { try {
await globals.processUtils.run( await processUtils.run(
<String>[ 'git', 'rev-parse', '@{u}'], <String>[ 'git', 'rev-parse', '@{u}'],
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
...@@ -232,7 +232,7 @@ class UpgradeCommandRunner { ...@@ -232,7 +232,7 @@ class UpgradeCommandRunner {
tag = 'v${gitTagVersion.x}.${gitTagVersion.y}.${gitTagVersion.z}'; tag = 'v${gitTagVersion.x}.${gitTagVersion.y}.${gitTagVersion.z}';
} }
try { try {
await globals.processUtils.run( await processUtils.run(
<String>['git', 'reset', '--hard', tag], <String>['git', 'reset', '--hard', tag],
throwOnError: true, throwOnError: true,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
...@@ -264,7 +264,7 @@ class UpgradeCommandRunner { ...@@ -264,7 +264,7 @@ class UpgradeCommandRunner {
/// If the fast forward lands us on the same channel and revision, then /// If the fast forward lands us on the same channel and revision, then
/// returns true, otherwise returns false. /// returns true, otherwise returns false.
Future<bool> attemptFastForward(FlutterVersion oldFlutterVersion) async { Future<bool> attemptFastForward(FlutterVersion oldFlutterVersion) async {
final int code = await globals.processUtils.stream( final int code = await processUtils.stream(
<String>['git', 'pull', '--ff'], <String>['git', 'pull', '--ff'],
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
mapFunction: (String line) => matchesGitLine(line) ? null : line, mapFunction: (String line) => matchesGitLine(line) ? null : line,
...@@ -293,7 +293,7 @@ class UpgradeCommandRunner { ...@@ -293,7 +293,7 @@ class UpgradeCommandRunner {
Future<void> precacheArtifacts() async { Future<void> precacheArtifacts() async {
globals.printStatus(''); globals.printStatus('');
globals.printStatus('Upgrading engine...'); globals.printStatus('Upgrading engine...');
final int code = await globals.processUtils.stream( final int code = await processUtils.stream(
<String>[ <String>[
globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache', globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache',
], ],
...@@ -321,7 +321,7 @@ class UpgradeCommandRunner { ...@@ -321,7 +321,7 @@ class UpgradeCommandRunner {
Future<void> runDoctor() async { Future<void> runDoctor() async {
globals.printStatus(''); globals.printStatus('');
globals.printStatus('Running flutter doctor...'); globals.printStatus('Running flutter doctor...');
await globals.processUtils.stream( await processUtils.stream(
<String>[ <String>[
globals.fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor', globals.fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor',
], ],
......
...@@ -44,7 +44,7 @@ class VersionCommand extends FlutterCommand { ...@@ -44,7 +44,7 @@ class VersionCommand extends FlutterCommand {
globals.flutterVersion.fetchTagsAndUpdate(); globals.flutterVersion.fetchTagsAndUpdate();
RunResult runResult; RunResult runResult;
try { try {
runResult = await globals.processUtils.run( runResult = await processUtils.run(
<String>['git', 'tag', '-l', 'v*', '--sort=-creatordate'], <String>['git', 'tag', '-l', 'v*', '--sort=-creatordate'],
throwOnError: true, throwOnError: true,
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
...@@ -112,7 +112,7 @@ class VersionCommand extends FlutterCommand { ...@@ -112,7 +112,7 @@ class VersionCommand extends FlutterCommand {
} }
try { try {
await globals.processUtils.run( await processUtils.run(
<String>['git', 'checkout', 'v$version'], <String>['git', 'checkout', 'v$version'],
throwOnError: true, throwOnError: true,
workingDirectory: Cache.flutterRoot, workingDirectory: Cache.flutterRoot,
...@@ -131,7 +131,7 @@ class VersionCommand extends FlutterCommand { ...@@ -131,7 +131,7 @@ class VersionCommand extends FlutterCommand {
// if necessary. // if necessary.
globals.printStatus(''); globals.printStatus('');
globals.printStatus('Downloading engine...'); globals.printStatus('Downloading engine...');
int code = await globals.processUtils.stream(<String>[ int code = await processUtils.stream(<String>[
globals.fs.path.join('bin', 'flutter'), globals.fs.path.join('bin', 'flutter'),
'--no-color', '--no-color',
'precache', 'precache',
...@@ -158,7 +158,7 @@ class VersionCommand extends FlutterCommand { ...@@ -158,7 +158,7 @@ class VersionCommand extends FlutterCommand {
// Run a doctor check in case system requirements have changed. // Run a doctor check in case system requirements have changed.
globals.printStatus(''); globals.printStatus('');
globals.printStatus('Running flutter doctor...'); globals.printStatus('Running flutter doctor...');
code = await globals.processUtils.stream( code = await processUtils.stream(
<String>[ <String>[
globals.fs.path.join('bin', 'flutter'), globals.fs.path.join('bin', 'flutter'),
'doctor', 'doctor',
......
...@@ -11,6 +11,7 @@ import '../base/context.dart'; ...@@ -11,6 +11,7 @@ import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart' as io; import '../base/io.dart' as io;
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../reporting/reporting.dart'; import '../reporting/reporting.dart';
...@@ -254,7 +255,7 @@ class _DefaultPub implements Pub { ...@@ -254,7 +255,7 @@ class _DefaultPub implements Pub {
int code; int code;
loop: while (true) { loop: while (true) {
attempts += 1; attempts += 1;
code = await globals.processUtils.stream( code = await processUtils.stream(
_pubCommand(arguments), _pubCommand(arguments),
workingDirectory: directory, workingDirectory: directory,
mapFunction: filterWrapper, // may set versionSolvingFailed, lastPubMessage mapFunction: filterWrapper, // may set versionSolvingFailed, lastPubMessage
...@@ -300,7 +301,7 @@ class _DefaultPub implements Pub { ...@@ -300,7 +301,7 @@ class _DefaultPub implements Pub {
String directory, String directory,
}) async { }) async {
Cache.releaseLockEarly(); Cache.releaseLockEarly();
final io.Process process = await globals.processUtils.start( final io.Process process = await processUtils.start(
_pubCommand(arguments), _pubCommand(arguments),
workingDirectory: directory, workingDirectory: directory,
environment: await _createPubEnvironment(PubContext.interactive), environment: await _createPubEnvironment(PubContext.interactive),
......
...@@ -13,6 +13,7 @@ import 'base/async_guard.dart'; ...@@ -13,6 +13,7 @@ import 'base/async_guard.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'base/process.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'base/user_messages.dart'; import 'base/user_messages.dart';
import 'base/utils.dart'; import 'base/utils.dart';
...@@ -666,7 +667,7 @@ class FlutterValidator extends DoctorValidator { ...@@ -666,7 +667,7 @@ class FlutterValidator extends DoctorValidator {
bool _genSnapshotRuns(String genSnapshotPath) { bool _genSnapshotRuns(String genSnapshotPath) {
const int kExpectedExitCode = 255; const int kExpectedExitCode = 255;
try { try {
return globals.processUtils.runSync(<String>[genSnapshotPath]).exitCode == kExpectedExitCode; return processUtils.runSync(<String>[genSnapshotPath]).exitCode == kExpectedExitCode;
} on Exception { } on Exception {
return false; return false;
} }
......
...@@ -120,7 +120,7 @@ class EmulatorManager { ...@@ -120,7 +120,7 @@ class EmulatorManager {
'-k', sdkId, '-k', sdkId,
'-d', device, '-d', device,
]; ];
final RunResult runResult = globals.processUtils.runSync(args, final RunResult runResult = processUtils.runSync(args,
environment: androidSdk?.sdkManagerEnv); environment: androidSdk?.sdkManagerEnv);
return CreateEmulatorResult( return CreateEmulatorResult(
name, name,
...@@ -141,7 +141,7 @@ class EmulatorManager { ...@@ -141,7 +141,7 @@ class EmulatorManager {
'device', 'device',
'-c', '-c',
]; ];
final RunResult runResult = globals.processUtils.runSync(args, final RunResult runResult = processUtils.runSync(args,
environment: androidSdk?.sdkManagerEnv); environment: androidSdk?.sdkManagerEnv);
if (runResult.exitCode != 0) { if (runResult.exitCode != 0) {
return null; return null;
...@@ -168,7 +168,7 @@ class EmulatorManager { ...@@ -168,7 +168,7 @@ class EmulatorManager {
'avd', 'avd',
'-n', 'temp', '-n', 'temp',
]; ];
final RunResult runResult = globals.processUtils.runSync(args, final RunResult runResult = processUtils.runSync(args,
environment: androidSdk?.sdkManagerEnv); environment: androidSdk?.sdkManagerEnv);
// Get the list of IDs that match our criteria // Get the list of IDs that match our criteria
......
...@@ -12,6 +12,7 @@ import '../base/common.dart'; ...@@ -12,6 +12,7 @@ import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart'; import '../bundle.dart';
...@@ -107,7 +108,7 @@ Future<void> _genSnapshot( ...@@ -107,7 +108,7 @@ Future<void> _genSnapshot(
timeout: null, timeout: null,
); );
try { try {
result = await globals.processUtils.stream(command, trace: true); result = await processUtils.stream(command, trace: true);
} finally { } finally {
status.cancel(); status.cancel();
} }
......
...@@ -575,7 +575,7 @@ class FuchsiaDevice extends Device { ...@@ -575,7 +575,7 @@ class FuchsiaDevice extends Device {
throwToolExit('Cannot interact with device. No ssh config.\n' throwToolExit('Cannot interact with device. No ssh config.\n'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'); 'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.');
} }
return await globals.processUtils.run(<String>[ return await processUtils.run(<String>[
'ssh', 'ssh',
'-F', '-F',
globals.fuchsiaArtifacts.sshConfig.absolute.path, globals.fuchsiaArtifacts.sshConfig.absolute.path,
...@@ -590,7 +590,7 @@ class FuchsiaDevice extends Device { ...@@ -590,7 +590,7 @@ class FuchsiaDevice extends Device {
throwToolExit('Cannot interact with device. No ssh config.\n' throwToolExit('Cannot interact with device. No ssh config.\n'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'); 'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.');
} }
return await globals.processUtils.run(<String>[ return await processUtils.run(<String>[
'scp', 'scp',
'-F', '-F',
globals.fuchsiaArtifacts.sshConfig.absolute.path, globals.fuchsiaArtifacts.sshConfig.absolute.path,
......
...@@ -7,6 +7,7 @@ import 'package:meta/meta.dart'; ...@@ -7,6 +7,7 @@ import 'package:meta/meta.dart';
import '../artifacts.dart'; import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
...@@ -94,7 +95,7 @@ class FuchsiaKernelCompiler { ...@@ -94,7 +95,7 @@ class FuchsiaKernelCompiler {
); );
int result; int result;
try { try {
result = await globals.processUtils.stream(command, trace: true); result = await processUtils.stream(command, trace: true);
} finally { } finally {
status.cancel(); status.cancel();
} }
......
...@@ -121,7 +121,7 @@ class FuchsiaPM { ...@@ -121,7 +121,7 @@ class FuchsiaPM {
'-l', '-l',
'$host:$port', '$host:$port',
]; ];
final Process process = await globals.processUtils.start(command); final Process process = await processUtils.start(command);
process.stdout process.stdout
.transform(utf8.decoder) .transform(utf8.decoder)
.transform(const LineSplitter()) .transform(const LineSplitter())
...@@ -155,7 +155,7 @@ class FuchsiaPM { ...@@ -155,7 +155,7 @@ class FuchsiaPM {
throwToolExit('Fuchsia pm tool not found'); throwToolExit('Fuchsia pm tool not found');
} }
final List<String> command = <String>[globals.fuchsiaArtifacts.pm.path, ...args]; final List<String> command = <String>[globals.fuchsiaArtifacts.pm.path, ...args];
final RunResult result = await globals.processUtils.run(command); final RunResult result = await processUtils.run(command);
return result.exitCode == 0; return result.exitCode == 0;
} }
} }
......
...@@ -17,7 +17,6 @@ import 'base/io.dart'; ...@@ -17,7 +17,6 @@ import 'base/io.dart';
import 'base/logger.dart'; import 'base/logger.dart';
import 'base/net.dart'; import 'base/net.dart';
import 'base/os.dart'; import 'base/os.dart';
import 'base/process.dart';
import 'base/template.dart'; import 'base/template.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'base/user_messages.dart'; import 'base/user_messages.dart';
...@@ -65,7 +64,6 @@ const ProcessManager _kLocalProcessManager = LocalProcessManager(); ...@@ -65,7 +64,6 @@ const ProcessManager _kLocalProcessManager = LocalProcessManager();
/// The active process manager. /// The active process manager.
ProcessManager get processManager => context.get<ProcessManager>() ?? _kLocalProcessManager; ProcessManager get processManager => context.get<ProcessManager>() ?? _kLocalProcessManager;
ProcessUtils get processUtils => context.get<ProcessUtils>();
const Platform _kLocalPlatform = LocalPlatform(); const Platform _kLocalPlatform = LocalPlatform();
......
...@@ -46,7 +46,7 @@ class IOSEmulator extends Emulator { ...@@ -46,7 +46,7 @@ class IOSEmulator extends Emulator {
globals.xcode.getSimulatorPath(), globals.xcode.getSimulatorPath(),
]; ];
final RunResult launchResult = await globals.processUtils.run(args); final RunResult launchResult = await processUtils.run(args);
if (launchResult.exitCode != 0) { if (launchResult.exitCode != 0) {
globals.printError('$launchResult'); globals.printError('$launchResult');
return false; return false;
......
...@@ -329,7 +329,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -329,7 +329,7 @@ Future<XcodeBuildResult> buildXcodeProject({
const Duration showBuildSettingsTimeout = Duration(minutes: 1); const Duration showBuildSettingsTimeout = Duration(minutes: 1);
Map<String, String> buildSettings; Map<String, String> buildSettings;
try { try {
final RunResult showBuildSettingsResult = await globals.processUtils.run( final RunResult showBuildSettingsResult = await processUtils.run(
showBuildSettingsCommand, showBuildSettingsCommand,
throwOnError: true, throwOnError: true,
workingDirectory: app.project.hostAppRoot.path, workingDirectory: app.project.hostAppRoot.path,
...@@ -413,7 +413,7 @@ Future<RunResult> _runBuildWithRetries(List<String> buildCommands, BuildableIOSA ...@@ -413,7 +413,7 @@ Future<RunResult> _runBuildWithRetries(List<String> buildCommands, BuildableIOSA
remainingTries--; remainingTries--;
buildRetryDelaySeconds *= 2; buildRetryDelaySeconds *= 2;
buildResult = await globals.processUtils.run( buildResult = await processUtils.run(
buildCommands, buildCommands,
workingDirectory: app.project.hostAppRoot.path, workingDirectory: app.project.hostAppRoot.path,
allowReentrantFlutter: true, allowReentrantFlutter: true,
......
...@@ -579,12 +579,12 @@ class IOSSimulator extends Device { ...@@ -579,12 +579,12 @@ class IOSSimulator extends Device {
Future<Process> launchDeviceLogTool(IOSSimulator device) async { Future<Process> launchDeviceLogTool(IOSSimulator device) async {
// Versions of iOS prior to iOS 11 log to the simulator syslog file. // Versions of iOS prior to iOS 11 log to the simulator syslog file.
if (await device.sdkMajorVersion < 11) { if (await device.sdkMajorVersion < 11) {
return globals.processUtils.start(<String>['tail', '-n', '0', '-F', device.logFilePath]); return processUtils.start(<String>['tail', '-n', '0', '-F', device.logFilePath]);
} }
// For iOS 11 and above, use /usr/bin/log to tail process logs. // For iOS 11 and above, use /usr/bin/log to tail process logs.
// Run in interactive mode (via script), otherwise /usr/bin/log buffers in 4k chunks. (radar: 34420207) // Run in interactive mode (via script), otherwise /usr/bin/log buffers in 4k chunks. (radar: 34420207)
return globals.processUtils.start(<String>[ return processUtils.start(<String>[
'script', '/dev/null', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"', 'script', '/dev/null', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
]); ]);
} }
...@@ -592,7 +592,7 @@ Future<Process> launchDeviceLogTool(IOSSimulator device) async { ...@@ -592,7 +592,7 @@ Future<Process> launchDeviceLogTool(IOSSimulator device) async {
Future<Process> launchSystemLogTool(IOSSimulator device) async { Future<Process> launchSystemLogTool(IOSSimulator device) async {
// Versions of iOS prior to 11 tail the simulator syslog file. // Versions of iOS prior to 11 tail the simulator syslog file.
if (await device.sdkMajorVersion < 11) { if (await device.sdkMajorVersion < 11) {
return globals.processUtils.start(<String>['tail', '-n', '0', '-F', '/private/var/log/system.log']); return processUtils.start(<String>['tail', '-n', '0', '-F', '/private/var/log/system.log']);
} }
// For iOS 11 and later, all relevant detail is in the device log. // For iOS 11 and later, all relevant detail is in the device log.
......
...@@ -6,6 +6,7 @@ import '../artifacts.dart'; ...@@ -6,6 +6,7 @@ import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
...@@ -72,7 +73,7 @@ export PROJECT_DIR=${linuxProject.project.directory.path} ...@@ -72,7 +73,7 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
); );
int result; int result;
try { try {
result = await globals.processUtils.stream(<String>[ result = await processUtils.stream(<String>[
'make', 'make',
'-C', '-C',
linuxProject.makeFile.parent.path, linuxProject.makeFile.parent.path,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../ios/xcodeproj.dart'; import '../ios/xcodeproj.dart';
...@@ -72,7 +73,7 @@ Future<void> buildMacOS({ ...@@ -72,7 +73,7 @@ Future<void> buildMacOS({
); );
int result; int result;
try { try {
result = await globals.processUtils.stream(<String>[ result = await processUtils.stream(<String>[
'/usr/bin/env', '/usr/bin/env',
'xcrun', 'xcrun',
'xcodebuild', 'xcodebuild',
......
...@@ -161,7 +161,7 @@ class CoverageCollector extends TestWatcher { ...@@ -161,7 +161,7 @@ class CoverageCollector extends TestWatcher {
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_test_coverage.'); final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_test_coverage.');
try { try {
final File sourceFile = coverageFile.copySync(globals.fs.path.join(tempDir.path, 'lcov.source.info')); final File sourceFile = coverageFile.copySync(globals.fs.path.join(tempDir.path, 'lcov.source.info'));
final RunResult result = globals.processUtils.runSync(<String>[ final RunResult result = processUtils.runSync(<String>[
'lcov', 'lcov',
'--add-tracefile', baseCoverageData, '--add-tracefile', baseCoverageData,
'--add-tracefile', sourceFile.path, '--add-tracefile', sourceFile.path,
......
...@@ -53,10 +53,10 @@ class FlutterVersion { ...@@ -53,10 +53,10 @@ class FlutterVersion {
FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) { FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) {
_frameworkRevision = _runGit( _frameworkRevision = _runGit(
gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '), gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '),
globals.processUtils, processUtils,
_workingDirectory, _workingDirectory,
); );
_gitTagVersion = GitTagVersion.determine(globals.processUtils, workingDirectory: _workingDirectory, fetchTags: false); _gitTagVersion = GitTagVersion.determine(processUtils, workingDirectory: _workingDirectory, fetchTags: false);
_frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision);
} }
...@@ -67,7 +67,7 @@ class FlutterVersion { ...@@ -67,7 +67,7 @@ class FlutterVersion {
/// user explicitly wants to get the version, e.g. for `flutter --version` or /// user explicitly wants to get the version, e.g. for `flutter --version` or
/// `flutter doctor`. /// `flutter doctor`.
void fetchTagsAndUpdate() { void fetchTagsAndUpdate() {
_gitTagVersion = GitTagVersion.determine(globals.processUtils, workingDirectory: _workingDirectory, fetchTags: true); _gitTagVersion = GitTagVersion.determine(processUtils, workingDirectory: _workingDirectory, fetchTags: true);
_frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision);
} }
...@@ -112,7 +112,7 @@ class FlutterVersion { ...@@ -112,7 +112,7 @@ class FlutterVersion {
if (_channel == null) { if (_channel == null) {
final String channel = _runGit( final String channel = _runGit(
'git rev-parse --abbrev-ref --symbolic @{u}', 'git rev-parse --abbrev-ref --symbolic @{u}',
globals.processUtils, processUtils,
_workingDirectory, _workingDirectory,
); );
final int slash = channel.indexOf('/'); final int slash = channel.indexOf('/');
...@@ -120,7 +120,7 @@ class FlutterVersion { ...@@ -120,7 +120,7 @@ class FlutterVersion {
final String remote = channel.substring(0, slash); final String remote = channel.substring(0, slash);
_repositoryUrl = _runGit( _repositoryUrl = _runGit(
'git ls-remote --get-url $remote', 'git ls-remote --get-url $remote',
globals.processUtils, processUtils,
_workingDirectory, _workingDirectory,
); );
_channel = channel.substring(slash + 1); _channel = channel.substring(slash + 1);
...@@ -148,7 +148,7 @@ class FlutterVersion { ...@@ -148,7 +148,7 @@ class FlutterVersion {
String get frameworkAge { String get frameworkAge {
return _frameworkAge ??= _runGit( return _frameworkAge ??= _runGit(
gitLog(<String>['-n', '1', '--pretty=format:%ar']).join(' '), gitLog(<String>['-n', '1', '--pretty=format:%ar']).join(' '),
globals.processUtils, processUtils,
_workingDirectory, _workingDirectory,
); );
} }
...@@ -288,7 +288,7 @@ class FlutterVersion { ...@@ -288,7 +288,7 @@ class FlutterVersion {
/// the branch name will be returned as `'[user-branch]'`. /// the branch name will be returned as `'[user-branch]'`.
String getBranchName({ bool redactUnknownBranches = false }) { String getBranchName({ bool redactUnknownBranches = false }) {
_branch ??= () { _branch ??= () {
final String branch = _runGit('git rev-parse --abbrev-ref HEAD', globals.processUtils); final String branch = _runGit('git rev-parse --abbrev-ref HEAD', processUtils);
return branch == 'HEAD' ? channel : branch; return branch == 'HEAD' ? channel : branch;
}(); }();
if (redactUnknownBranches || _branch.isEmpty) { if (redactUnknownBranches || _branch.isEmpty) {
......
...@@ -6,6 +6,7 @@ import '../artifacts.dart'; ...@@ -6,6 +6,7 @@ import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
...@@ -85,7 +86,7 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, { ...@@ -85,7 +86,7 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
// Run the script with a relative path to the project using the enclosing // Run the script with a relative path to the project using the enclosing
// directory as the workingDirectory, to avoid hitting the limit on command // directory as the workingDirectory, to avoid hitting the limit on command
// lengths in batch scripts if the absolute path to the project is long. // lengths in batch scripts if the absolute path to the project is long.
result = await globals.processUtils.stream(<String>[ result = await processUtils.stream(<String>[
buildScript, buildScript,
vcvarsScript, vcvarsScript,
globals.fs.path.basename(solutionPath), globals.fs.path.basename(solutionPath),
......
...@@ -87,7 +87,7 @@ final RegExp _whitespace = RegExp(r'\s+'); ...@@ -87,7 +87,7 @@ final RegExp _whitespace = RegExp(r'\s+');
@visibleForTesting @visibleForTesting
List<String> runningProcess(String processName) { List<String> runningProcess(String processName) {
// TODO(jonahwilliams): find a way to do this without powershell. // TODO(jonahwilliams): find a way to do this without powershell.
final RunResult result = globals.processUtils.runSync( final RunResult result = processUtils.runSync(
<String>['powershell', '-script="Get-CimInstance Win32_Process"'], <String>['powershell', '-script="Get-CimInstance Win32_Process"'],
); );
if (result.exitCode != 0) { if (result.exitCode != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment