Commit 358e1cd2 authored by Kevin Moore's avatar Kevin Moore Committed by John McCutchan

Teach flutter_tools to populate PUB_ENVIRONMENT (#8962)

* Teach flutter_tools to populate PUB_ENVIRONMENT

Will allow telemetry reporting on pub.dartlang.org once
flutter moves to 1.23.0-dev.10.0

* review changes
parent f47cde44
...@@ -7,7 +7,9 @@ import 'dart:async'; ...@@ -7,7 +7,9 @@ import 'dart:async';
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/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/utils.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart'; import '../globals.dart';
import 'sdk.dart'; import 'sdk.dart';
...@@ -54,7 +56,7 @@ Future<Null> pubGet({ ...@@ -54,7 +56,7 @@ Future<Null> pubGet({
final int code = await runCommandAndStreamOutput(args, final int code = await runCommandAndStreamOutput(args,
workingDirectory: directory, workingDirectory: directory,
mapFunction: _filterOverrideWarnings, mapFunction: _filterOverrideWarnings,
environment: <String, String>{ 'FLUTTER_ROOT': Cache.flutterRoot } environment: <String, String>{ 'FLUTTER_ROOT': Cache.flutterRoot, _pubEnvironmentKey: _getPubEnvironmentValue() }
); );
status.stop(); status.stop();
if (code != 0) if (code != 0)
...@@ -70,6 +72,30 @@ Future<Null> pubGet({ ...@@ -70,6 +72,30 @@ Future<Null> pubGet({
final RegExp _analyzerWarning = new RegExp(r'^! \w+ [^ ]+ from path \.\./\.\./bin/cache/dart-sdk/lib/\w+$'); final RegExp _analyzerWarning = new RegExp(r'^! \w+ [^ ]+ from path \.\./\.\./bin/cache/dart-sdk/lib/\w+$');
/// The console environment key used by the pub tool.
const String _pubEnvironmentKey = 'PUB_ENVIRONMENT';
/// 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_cli');
return values.join(':');
}
String _filterOverrideWarnings(String message) { String _filterOverrideWarnings(String message) {
// This function filters out these three messages: // This function filters out these three messages:
// Warning: You are using these overridden dependencies: // Warning: You are using these overridden dependencies:
......
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