diff --git a/src/recipe/lang/Dart.c b/src/recipe/lang/Dart.c index 3e55ec4..ee223df 100644 --- a/src/recipe/lang/Dart.c +++ b/src/recipe/lang/Dart.c @@ -4,7 +4,8 @@ * File Authors : Aoran Zeng <ccmywish@qq.com> * Contributors : Nil Null <nil@null.org> * Created On : <2023-09-10> - * Last Modified : <2024-08-15> + * Last Modified : <2024-08-28> + * Revision : 2 * ------------------------------------------------------------*/ /** @@ -26,6 +27,7 @@ pl_dart_sources[] = { }; def_sources_n(pl_dart); + void pl_dart_getsrc (char *option) { @@ -50,40 +52,67 @@ pl_dart_setsrc (char *option) { chsrc_yield_source_and_confirm (pl_dart); - char *towrite = NULL; + char *towrite1, *towrite2 = NULL; - char *pub = xy_2strjoin(source.url, "dart-pub"); - char *flutter = xy_2strjoin(source.url, "flutter"); + char *pub = xy_2strjoin (source.url, "dart-pub"); + char *flutter = xy_2strjoin (source.url, "flutter"); if (xy_on_windows) { + towrite1 = xy_strjoin (3, "$env:PUB_HOSTED_URL = \"", pub, "\""); + towrite2 = xy_strjoin (3, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\""); + if (xy_file_exist (xy_win_powershell_profile)) { - towrite = xy_strjoin (4, "$env:PUB_HOSTED_URL = \"", pub, "\""); - chsrc_append_to_file (towrite, xy_win_powershell_profile); - - towrite = xy_strjoin (4, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\""); - chsrc_append_to_file (towrite, xy_win_powershell_profile); + chsrc_append_to_file (towrite1, xy_win_powershell_profile); + chsrc_append_to_file (towrite2, xy_win_powershell_profile); } if (xy_file_exist (xy_win_powershellv5_profile)) { - towrite = xy_strjoin (4, "$env:PUB_HOSTED_URL = \"", pub, "\""); - chsrc_append_to_file (towrite, xy_win_powershellv5_profile); - - towrite = xy_strjoin (4, "$env:FLUTTER_STORAGE_BASE_URL = \"", flutter, "\""); - chsrc_append_to_file (towrite, xy_win_powershellv5_profile); + chsrc_append_to_file (towrite1, xy_win_powershellv5_profile); + chsrc_append_to_file (towrite2, xy_win_powershellv5_profile); } } else { - towrite = xy_strjoin (3, "export PUB_HOSTED_URL=\"", pub, "\""); - chsrc_append_to_file (towrite, "~/.bashrc >> ~/.zshrc"); + char *zshrc = "~/.zshrc"; + char *bashrc = "~/.bashrc"; - towrite = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", flutter, "\""); - chsrc_append_to_file (towrite, "~/.bashrc >> ~/.zshrc"); + chsrc_backup (zshrc); + towrite1 = xy_strjoin (3, "export PUB_HOSTED_URL=\"", pub, "\""); + towrite2 = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", flutter, "\""); + chsrc_append_to_file (towrite1, zshrc); + chsrc_append_to_file (towrite2, zshrc); + + if (xy_file_exist (bashrc)) + { + chsrc_backup (bashrc); + chsrc_append_to_file (towrite1, bashrc); + chsrc_append_to_file (towrite2, bashrc); + } } chsrc_conclude (&source, ChsrcTypeUntested); } -def_target(pl_dart); + +FeatInfo +pl_dart_feat (char *option) +{ + FeatInfo fi = {0}; + + fi.can_get = true; + fi.can_reset = false; + + fi.stcan_locally = CanNot; + fi.locally = NULL; + fi.can_english = true; + + /* 该换源方案中,URL存在拼凑,因此不能让用户手动使用某URL来换源 */ + fi.can_user_define = false; + + fi.note = "该换源通过写入环境变量实现,若多次换源,请手动清理profile文件"; + return fi; +} + +def_target_gsf(pl_dart);