Ensure compatibility with older PowerShell versions and better error handling (#8652)

This should make our scripts compatible with PowerShell 2 or newer. PowerShell 2 was released in October 2009 and shipped with Windows 7 as default. (I suspect the scripts are now also compatible with PowerShell 1, but that's unconfirmed). This fixes #8606.

The PR also introduces better error handling when Flutter fail to download the Dart SDK to fix #8627.
This commit is contained in:
Michael Goderbauer
2017-03-08 10:52:07 -08:00
committed by GitHub
parent 0136b965e8
commit e2dccc5e48
3 changed files with 24 additions and 5 deletions

View File

@@ -29,11 +29,11 @@ SET dart=%dart_sdk_path%\bin\dart.exe
SET pub=%dart_sdk_path%\bin\pub.bat
REM Test if Git is available on the Host
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT 1
REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail
IF NOT EXIST "%flutter_root%\.git" (
ECHO Error: The Flutter directory is not a clone of the GitHub project.
EXIT /B 1
EXIT 1
)
REM Ensure that bin/cache exists.
@@ -80,6 +80,12 @@ GOTO :after_subroutine
:do_sdk_update_and_snapshot
ECHO Checking Dart SDK version...
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
SET exit_code=%ERRORLEVEL%
IF %exit_code% NEQ 0 (
ECHO Error: Unable to update Dart SDK.
REM Do not use /B here, we want to exit out of the script, not just the subroutine
EXIT %exit_code%
)
:do_snapshot
ECHO: > "%cache_dir%\.dartignore"
@@ -105,4 +111,4 @@ IF /I "%exit_code%" EQU "253" (
SET exit_code=%ERRORLEVEL%
)
EXIT /B %exit_code%
EXIT %exit_code%