diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index ffe0f66a97e..3038bb4d9d1 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart @@ -22,7 +22,7 @@ Future runCommand(List cmd, { String workingDirectory, bool allowReentrantFlutter: false }) async { - printTrace(cmd.join(' ')); + _traceCommand(cmd, workingDirectory: workingDirectory); String executable = cmd[0]; List arguments = cmd.length > 1 ? cmd.sublist(1) : []; Process process = await Process.start( @@ -86,7 +86,7 @@ Future runAndKill(List cmd, Duration timeout) { } Future runDetached(List cmd) { - printTrace(cmd.join(' ')); + _traceCommand(cmd); Future proc = Process.start( cmd[0], cmd.getRange(1, cmd.length).toList(), mode: ProcessStartMode.DETACHED @@ -98,7 +98,7 @@ Future runAsync(List cmd, { String workingDirectory, bool allowReentrantFlutter: false }) async { - printTrace(cmd.join(' ')); + _traceCommand(cmd, workingDirectory: workingDirectory); ProcessResult results = await Process.run( cmd[0], cmd.getRange(1, cmd.length).toList(), @@ -111,7 +111,7 @@ Future runAsync(List cmd, { } bool exitsHappy(List cli) { - printTrace(cli.join(' ')); + _traceCommand(cli); try { return Process.runSync(cli.first, cli.sublist(1)).exitCode == 0; } catch (error) { @@ -124,16 +124,14 @@ bool exitsHappy(List cli) { /// Throws an error if cmd exits with a non-zero value. String runCheckedSync(List cmd, { String workingDirectory, - bool allowReentrantFlutter: false, - bool truncateCommand: false + bool allowReentrantFlutter: false }) { return _runWithLoggingSync( cmd, workingDirectory: workingDirectory, allowReentrantFlutter: allowReentrantFlutter, checked: true, - noisyErrors: true, - truncateCommand: truncateCommand + noisyErrors: true ); } @@ -149,17 +147,24 @@ String runSync(List cmd, { ); } +void _traceCommand(List args, { String workingDirectory }) { + final int kMaxArgsLength = 1024; + String argsText = args.join(' '); + if (argsText.length > kMaxArgsLength) + argsText = argsText.substring(0, kMaxArgsLength) + '…'; + if (workingDirectory == null) + printTrace(argsText); + else + printTrace("[$workingDirectory${Platform.pathSeparator}] $argsText"); +} + String _runWithLoggingSync(List cmd, { bool checked: false, bool noisyErrors: false, String workingDirectory, - bool allowReentrantFlutter: false, - bool truncateCommand: false + bool allowReentrantFlutter: false }) { - String cmdText = cmd.join(' '); - if (truncateCommand && cmdText.length > 160) - cmdText = cmdText.substring(0, 160) + '…'; - printTrace(cmdText); + _traceCommand(cmd, workingDirectory: workingDirectory); ProcessResult results = Process.runSync( cmd[0], cmd.getRange(1, cmd.length).toList(), diff --git a/packages/flutter_tools/lib/src/zip.dart b/packages/flutter_tools/lib/src/zip.dart index 158efbc1e60..d1929cb1d39 100644 --- a/packages/flutter_tools/lib/src/zip.dart +++ b/packages/flutter_tools/lib/src/zip.dart @@ -74,16 +74,14 @@ class _ZipToolBuilder extends ZipBuilder { if (_getCompressedNames().isNotEmpty) { runCheckedSync( ['zip', '-q', outFile.absolute.path]..addAll(_getCompressedNames()), - workingDirectory: zipBuildDir.path, - truncateCommand: true + workingDirectory: zipBuildDir.path ); } if (_getStoredNames().isNotEmpty) { runCheckedSync( ['zip', '-q', '-0', outFile.absolute.path]..addAll(_getStoredNames()), - workingDirectory: zipBuildDir.path, - truncateCommand: true + workingDirectory: zipBuildDir.path ); } }