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);