Skip to content

Commit 984fa36

Browse files
committed
优化 AndroidX 和 Support 互转脚本生成的文件名称
1 parent 088472c commit 984fa36

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

shell/package-tools/AndroidXToSupport.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ main() {
4040
exit 1
4141
fi
4242

43-
supportFilePath="${androidXFilePath%.*}-support-$(date "+%Y%m%d%H%M%S").${androidXFilePath##*.}"
43+
supportFilePath="${androidXFilePath%.*}-support.${androidXFilePath##*.}"
44+
supportNameSuffix="-$(date "+%Y%m%d%H%M%S")"
45+
if [[ -f "${supportFilePath}" ]]; then
46+
supportFilePath="${supportFilePath%.*}${supportNameSuffix}.${androidXFilePath##*.}"
47+
elif [[ -d "${supportFilePath}" ]]; then
48+
if [[ "$(find "${supportFilePath}" -mindepth 1 | head -1)" ]]; then
49+
supportFilePath="${supportFilePath%.*}${supportNameSuffix}.${androidXFilePath##*.}"
50+
else
51+
rmdir "${supportFilePath}"
52+
fi
53+
fi
4454
echo "support 包的保存路径:${supportFilePath}"
4555

4656
outputPrint="$("${resourcesDirPath}$(getFileSeparator)jetifier-standalone-20200827$(getFileSeparator)bin$(getFileSeparator)jetifier-standalone" -r -i "${androidXFilePath}" -o "${supportFilePath}" 2>&1)"

shell/package-tools/SupportToAndroidX.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ main() {
4040
exit 1
4141
fi
4242

43-
androidXFilePath="${supportFilePath%.*}-androidx-$(date "+%Y%m%d%H%M%S").${supportFilePath##*.}"
43+
androidXFilePath="${supportFilePath%.*}-androidx.${supportFilePath##*.}"
44+
androidxNameSuffix="-$(date "+%Y%m%d%H%M%S")"
45+
if [[ -f "${androidXFilePath}" ]]; then
46+
androidXFilePath="${androidXFilePath%.*}${androidxNameSuffix}.${supportFilePath##*.}"
47+
elif [[ -d "${androidXFilePath}" ]]; then
48+
if [[ "$(find "${androidXFilePath}" -mindepth 1 | head -1)" ]]; then
49+
androidXFilePath="${androidXFilePath%.*}${androidxNameSuffix}.${supportFilePath##*.}"
50+
else
51+
rmdir "${androidXFilePath}"
52+
fi
53+
fi
4454
echo "androidx 包的保存路径:${androidXFilePath}"
4555

4656
outputPrint="$("${resourcesDirPath}$(getFileSeparator)jetifier-standalone-20200827$(getFileSeparator)bin$(getFileSeparator)jetifier-standalone" -i "${supportFilePath}" -o "${androidXFilePath}" 2>&1)"

0 commit comments

Comments
 (0)