Fix append only once

[GitHub #76]
This commit is contained in:
Aoran Zeng
2024-11-22 02:04:36 +08:00
parent c1c495cf6d
commit 7825acfff3
7 changed files with 57 additions and 42 deletions

View File

@@ -56,17 +56,17 @@ pl_dart_flutter_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_dart_flutter);
char *towrite = NULL;
char *w = NULL;
if (xy_on_windows)
{
towrite = xy_strjoin (3, "$env:FLUTTER_STORAGE_BASE_URL = \"", source.url, "\"");
w = xy_strjoin (3, "$env:FLUTTER_STORAGE_BASE_URL = \"", source.url, "\"\n");
if (xy_file_exist (xy_win_powershell_profile))
chsrc_append_to_file (towrite, xy_win_powershell_profile);
chsrc_append_to_file (w, xy_win_powershell_profile);
if (xy_file_exist (xy_win_powershellv5_profile))
chsrc_append_to_file (towrite, xy_win_powershellv5_profile);
chsrc_append_to_file (w, xy_win_powershellv5_profile);
}
else
{
@@ -74,13 +74,13 @@ pl_dart_flutter_setsrc (char *option)
char *bashrc = "~/.bashrc";
chsrc_backup (zshrc);
towrite = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"");
chsrc_append_to_file (towrite, zshrc);
w = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n");
chsrc_append_to_file (w, zshrc);
if (xy_file_exist (bashrc))
{
chsrc_backup (bashrc);
chsrc_append_to_file (towrite, bashrc);
chsrc_append_to_file (w, bashrc);
}
}
chsrc_conclude (&source, SetsrcType_Auto);

View File

@@ -51,17 +51,17 @@ pl_dart_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_dart);
char *towrite = NULL;
char *w = NULL;
if (xy_on_windows)
{
towrite = xy_strjoin (3, "$env:PUB_HOSTED_URL = \"", source.url, "\"");
w = xy_strjoin (3, "$env:PUB_HOSTED_URL = \"", source.url, "\"\n");
if (xy_file_exist (xy_win_powershell_profile))
chsrc_append_to_file (towrite, xy_win_powershell_profile);
chsrc_append_to_file (w, xy_win_powershell_profile);
if (xy_file_exist (xy_win_powershellv5_profile))
chsrc_append_to_file (towrite, xy_win_powershellv5_profile);
chsrc_append_to_file (w, xy_win_powershellv5_profile);
}
else
{
@@ -69,14 +69,14 @@ pl_dart_setsrc (char *option)
char *bashrc = "~/.bashrc";
chsrc_backup (zshrc);
towrite = xy_strjoin (3, "export PUB_HOSTED_URL=\"", source.url, "\"");
w = xy_strjoin (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n");
chsrc_append_to_file (towrite, zshrc);
chsrc_append_to_file (w, zshrc);
if (xy_file_exist (bashrc))
{
chsrc_backup (bashrc);
chsrc_append_to_file (towrite, bashrc);
chsrc_append_to_file (w, bashrc);
}
}
chsrc_conclude (&source, SetsrcType_Auto);

View File

@@ -32,7 +32,7 @@ pl_nodejs_nvm_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_nodejs_binary_release);
char *w = xy_2strjoin ("export NVM_NODEJS_ORG_MIRROR=", source.url);
char *w = xy_strjoin (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n");
char *zshrc = "~/.zshrc";
char *bashrc = "~/.bashrc";

View File

@@ -50,7 +50,7 @@ pl_r_getsrc (char *option)
}
/**
* R 换源,参考:https://help.mirrors.cernet.edu.cn/CRAN/
* @consult https://help.mirrors.cernet.edu.cn/CRAN/
*/
void
pl_r_setsrc (char *option)
@@ -60,8 +60,8 @@ pl_r_setsrc (char *option)
char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/");
bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor");
const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))" );
const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")" );
const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" );
const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" );
char *w = xy_2strjoin (w1, w2);

View File

@@ -52,7 +52,7 @@ pl_rust_rustup_setsrc (char *option)
char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n");
char *w = xy_2strjoin (w1, w2)
char *w = xy_2strjoin (w1, w2);
char *bashrc = "~/.bashrc";
if (xy_file_exist (bashrc))
@@ -74,7 +74,7 @@ pl_rust_rustup_setsrc (char *option)
char *w1 = xy_strjoin (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n");
char *w2 = xy_strjoin (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n");
char *w = xy_2strjoin (w1, w2)
char *w = xy_2strjoin (w1, w2);
chsrc_backup (fishrc);
chsrc_append_to_file (w, fishrc);