Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/flutter
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fi
"$FLUTTER_ROOT/bin/internal/update_dart_sdk.sh"

echo Building flutter tool...
(cd "$FLUTTER_TOOLS_DIR"; "$PUB" upgrade --verbosity=error --no-packages-dir)
(cd "$FLUTTER_TOOLS_DIR"; "$DART" tool/pub_upgrade.dart "$PUB")
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
echo $REVISION > "$STAMP_PATH"
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/flutter.bat
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ GOTO :after_subroutine
ECHO: > "%cache_dir%\.dartignore"
ECHO Updating flutter tool...
PUSHD "%flutter_tools_dir%"
CALL "%pub%" upgrade --verbosity=error --no-packages-dir
CALL "%dart%" tool\pub_upgrade.dart "%pub%"
POPD
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
>"%stamp_path%" ECHO %revision%
Expand Down
58 changes: 58 additions & 0 deletions packages/flutter_tools/tool/pub_upgrade.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'dart:async';
import 'dart:io';

Future<Null> main(List<String> args) async {
String pub = 'pub';
if (args.isNotEmpty) {
pub = args.single;
}

final Process process = await Process.start(pub, <String>[
'upgrade',
'--verbosity=error'
], environment: <String, String>{
_pubEnvironmentKey: _getPubEnvironmentValue()
});

final List<dynamic> result =
await Future.wait<Future<dynamic>>(<Future<dynamic>>[
process.exitCode,
process.stdout.forEach(stdout.write),
process.stderr.forEach(stderr.write)
]);

exitCode = result.first;
}

/// Returns the environment value that should be used when running pub.
///
/// Includes any existing environment variable, if one exists.
String _getPubEnvironmentValue() {
final List<String> values = <String>[];

final String existing = Platform.environment[_pubEnvironmentKey];

if ((existing != null) && existing.isNotEmpty) {
values.add(existing);
}

if (_isRunningOnBot) {
values.add('flutter_bot');
}

values.add('flutter_install');

return values.join(':');
}

/// The console environment key used by the pub tool.
const String _pubEnvironmentKey = 'PUB_ENVIRONMENT';

bool get _isRunningOnBot {
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
// CHROME_HEADLESS is one property set on Flutter's Chrome Infra bots.
return Platform.environment['TRAVIS'] == 'true' ||
Platform.environment['BOT'] == 'true' ||
Platform.environment['CONTINUOUS_INTEGRATION'] == 'true' ||
Platform.environment['CHROME_HEADLESS'] == '1';
}