@@ -51,7 +51,7 @@ download_archive() {
5151 if [[ " $archive_name " == * zip ]]; then
5252 EXTRACT_PATH=" $RUNNER_TEMP /_unzip_temp"
5353 unzip -q -o " $archive_local " -d " $EXTRACT_PATH "
54- # Remove the folder again so that the move command can do a simple rename\
54+ # Remove the folder again so that the move command can do a simple rename
5555 # instead of moving the content into the target folder.
5656 # This is a little bit of a hack since the "mv --no-target-directory"
5757 # linux option is not available here
@@ -67,17 +67,19 @@ download_archive() {
6767
6868CACHE_PATH=" "
6969CACHE_KEY=" "
70+ PUB_CACHE_PATH=" "
7071PUB_CACHE_KEY=" "
7172PRINT_ONLY=" "
7273TEST_MODE=false
7374ARCH=" "
7475VERSION=" "
7576
76- while getopts ' tc:k:d:pa:n:' flag; do
77+ while getopts ' tc:k:d:l: pa:n:' flag; do
7778 case " $flag " in
7879 c) CACHE_PATH=" $OPTARG " ;;
7980 k) CACHE_KEY=" $OPTARG " ;;
80- d) PUB_CACHE_KEY=" $OPTARG " ;;
81+ d) PUB_CACHE_PATH=" $OPTARG " ;;
82+ l) PUB_CACHE_KEY=" $OPTARG " ;;
8183 p) PRINT_ONLY=true ;;
8284 t) TEST_MODE=true ;;
8385 a) ARCH=" $( echo " $OPTARG " | awk ' {print tolower($0)}' ) " ;;
@@ -97,8 +99,23 @@ CHANNEL="${ARR_CHANNEL[0]}"
9799[[ -z $CACHE_PATH ]] && CACHE_PATH=" $RUNNER_TEMP /flutter/:channel:-:version:-:arch:"
98100[[ -z $CACHE_KEY ]] && CACHE_KEY=" flutter-:os:-:channel:-:version:-:arch:-:hash:"
99101[[ -z $PUB_CACHE_KEY ]] && PUB_CACHE_KEY=" flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
100- # Here we specifically use `PUB_CACHE` (and not `PUB_CACHE_PATH`), because `PUB_CACHE` is what dart (and flutter) looks for in the environment
101- [[ -z $PUB_CACHE ]] && PUB_CACHE=" $HOME /.pub-cache"
102+ [[ -z $PUB_CACHE_PATH ]] && PUB_CACHE_PATH=" default"
103+
104+ # `PUB_CACHE` is what Dart and Flutter looks for in the environment, while
105+ # `PUB_CACHE_PATH` is passed in from the action.
106+ #
107+ # If `PUB_CACHE` is set already, then it should continue to be used. Otherwise, satisfy it
108+ # if the action requests a custom path, or set to the Dart default values depending
109+ # on the operating system.
110+ if [ -z " $PUB_CACHE " ]; then
111+ if [ " $PUB_CACHE_PATH " != " default" ]; then
112+ PUB_CACHE=" $PUB_CACHE_PATH "
113+ elif [ " $OS_NAME " == " windows" ]; then
114+ PUB_CACHE=" $LOCALAPPDATA \\ Pub\\ Cache"
115+ else
116+ PUB_CACHE=" $HOME /.pub-cache"
117+ fi
118+ fi
102119
103120if [[ " $TEST_MODE " == true ]]; then
104121 RELEASE_MANIFEST=$( cat " $( dirname -- " ${BASH_SOURCE[0]} " ) /test/$MANIFEST_JSON_PATH " )
0 commit comments