Skip to content

Commit 6e11856

Browse files
authored
Change behavior of DEVTOOLS_TOOL_FLUTTER_FROM_PATH (#10001)
1 parent c49302e commit 6e11856

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

tool/bin/dt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44

55
USE_PATH=false
6-
if [ ! -z "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" ]; then
6+
if [ "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" = "true" ]; then
77
USE_PATH=true
88
fi
99
for arg in "$@"; do

tool/bin/dt.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REM found in the LICENSE file or at https://developers.google.com/open-source/li
44
@echo off
55

66
set USE_PATH=
7-
IF DEFINED DEVTOOLS_TOOL_FLUTTER_FROM_PATH set USE_PATH=1
7+
IF /I "%DEVTOOLS_TOOL_FLUTTER_FROM_PATH%"=="true" set USE_PATH=1
88
for %%a in (%*) do (
99
if "%%a"=="-p" set USE_PATH=1
1010
if "%%a"=="--flutter-from-path" set USE_PATH=1

tool/ci/setup.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function flutter {
2222
export -f flutter
2323

2424
# Determine the Flutter SDK to use:
25-
# * If `DEVTOOLS_TOOL_FLUTTER_FROM_PATH` is set, then discover from `PATH`.
25+
# * If `DEVTOOLS_TOOL_FLUTTER_FROM_PATH` is "true", then discover from `PATH`.
2626
# * If `./tool/flutter-sdk` (a directory) exists, then use that.
27-
if [ -n "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" ]; then
27+
if [ "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" = "true" ]; then
2828
if command -v flutter &> /dev/null; then
2929
FLUTTER_EXE="$(command -v flutter)"
3030
elif command -v flutter.bat &> /dev/null; then
3131
FLUTTER_EXE="$(command -v flutter.bat)"
3232
else
33-
echo "DEVTOOLS_TOOL_FLUTTER_FROM_PATH is set, but flutter was not found on PATH"
33+
echo "DEVTOOLS_TOOL_FLUTTER_FROM_PATH is set to true, but flutter was not found on PATH"
3434
exit 1
3535
fi
3636
FLUTTER_BIN="$(cd "$(dirname "$FLUTTER_EXE")" && pwd -P)"
@@ -40,7 +40,7 @@ if [ -n "$DEVTOOLS_TOOL_FLUTTER_FROM_PATH" ]; then
4040
elif [ -d "./tool/flutter-sdk" ]; then
4141
FLUTTER_DIR="$(pwd)/tool/flutter-sdk"
4242
else
43-
echo "Expected ./tool/flutter-sdk to exist, or DEVTOOLS_TOOL_FLUTTER_FROM_PATH to be set"
43+
echo "Expected ./tool/flutter-sdk to exist, or DEVTOOLS_TOOL_FLUTTER_FROM_PATH to be set to true"
4444
exit 1
4545
fi
4646

tool/lib/devtools_command_runner.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ class DevToolsCommandRunner extends CommandRunner {
8282

8383
@override
8484
Future<void> runCommand(ArgResults topLevelResults) {
85+
final flutterFromPathEnvValue =
86+
Platform.environment[_flutterFromPathEnvVar] ?? '';
8587
final flutterFromPathEnv =
86-
Platform.environment[_flutterFromPathEnvVar]?.isNotEmpty == true;
88+
bool.tryParse(flutterFromPathEnvValue, caseSensitive: false) == true;
8789
if (topLevelResults.flag(_flutterFromPathFlag) &&
8890
topLevelResults.wasParsed(_flutterSdkPathFlag)) {
8991
throw ArgParserException(

0 commit comments

Comments
 (0)