Format changing output

This commit is contained in:
Aoran Zeng 2024-09-10 19:10:06 +08:00
parent 135444cd47
commit e0fccebf53
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
4 changed files with 36 additions and 15 deletions

View File

@ -51,14 +51,25 @@ pl_nodejs_getsrc (char *option)
bool npm_exist, yarn_exist, pnpm_exist; bool npm_exist, yarn_exist, pnpm_exist;
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist); pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
split_between_source_changing_process;
if (npm_exist) if (npm_exist)
pl_nodejs_npm_getsrc (option); {
pl_nodejs_npm_getsrc (option);
say ("");
}
if (yarn_exist) if (yarn_exist)
pl_nodejs_yarn_getsrc (option); {
pl_nodejs_yarn_getsrc (option);
say ("");
}
if (pnpm_exist) if (pnpm_exist)
pl_nodejs_pnpm_getsrc (option); {
pl_nodejs_pnpm_getsrc (option);
say ("");
}
} }
@ -72,15 +83,25 @@ pl_nodejs_setsrc (char *option)
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist); pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
// chsrc_yield_source_and_confirm (pl_nodejs); // chsrc_yield_source_and_confirm (pl_nodejs);
split_between_source_changing_process;
if (npm_exist) if (npm_exist)
pl_nodejs_npm_setsrc (option); {
pl_nodejs_npm_setsrc (option);
say ("");
}
if (yarn_exist) if (yarn_exist)
pl_nodejs_yarn_setsrc (option); {
pl_nodejs_yarn_setsrc (option);
say ("");
}
if (pnpm_exist) if (pnpm_exist)
pl_nodejs_pnpm_setsrc (option); {
pl_nodejs_pnpm_setsrc (option);
say ("");
}
// chsrc_conclude (&source, ChsrcTypeAuto); // chsrc_conclude (&source, ChsrcTypeAuto);
} }
@ -107,7 +128,7 @@ pl_nodejs_feat (char *option)
fi.can_get = true; fi.can_get = true;
fi.can_reset = true; fi.can_reset = true;
fi.stcan_locally = CanSemi; fi.stcan_locally = CanFully;
fi.locally = "Support npm (chsrc v0.1.7)\nSupport yarn v2 (chsrc v0.1.8.1)\nSupport pnpm (chsrc v0.1.8.2)"; fi.locally = "Support npm (chsrc v0.1.7)\nSupport yarn v2 (chsrc v0.1.8.1)\nSupport pnpm (chsrc v0.1.8.2)";
fi.can_english = true; fi.can_english = true;
fi.can_user_define = true; fi.can_user_define = true;

View File

@ -40,9 +40,9 @@ pl_nodejs_yarn_getsrc (char *option)
if (pl_nodejs_yarn_get_yarn_version () >= 2) if (pl_nodejs_yarn_get_yarn_version () >= 2)
// https://github.com/RubyMetric/chsrc/issues/53 // https://github.com/RubyMetric/chsrc/issues/53
// 从 Yarn V2 开始,使用新的配置名 // 从 Yarn V2 开始,使用新的配置名
chsrc_run ("yarn config get npmRegistryServer", RunOpt_Default); chsrc_run ("yarn config get npmRegistryServer", RunOpt_No_Last_New_Line);
else else
chsrc_run ("yarn config get registry", RunOpt_Default); chsrc_run ("yarn config get registry", RunOpt_No_Last_New_Line);
} }
@ -65,13 +65,13 @@ pl_nodejs_yarn_setsrc (char *option)
else else
cmd = xy_2strjoin ("yarn config set npmRegistryServer --home ", source.url); cmd = xy_2strjoin ("yarn config set npmRegistryServer --home ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
else else
{ {
// 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd() // 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd()
cmd = xy_2strjoin ("yarn config set registry ", source.url); cmd = xy_2strjoin ("yarn config set registry ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
chsrc_conclude (&source, ChsrcTypeAuto); chsrc_conclude (&source, ChsrcTypeAuto);

View File

@ -27,7 +27,7 @@ def_sources_n(pl_nodejs_npm);
void void
pl_nodejs_npm_getsrc (char *option) pl_nodejs_npm_getsrc (char *option)
{ {
chsrc_run ("npm config get registry", RunOpt_Default); chsrc_run ("npm config get registry", RunOpt_No_Last_New_Line);
} }
@ -48,7 +48,7 @@ pl_nodejs_npm_setsrc (char *option)
else else
cmd = xy_2strjoin ("npm config set registry ", source.url); cmd = xy_2strjoin ("npm config set registry ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_conclude (&source, ChsrcTypeAuto); chsrc_conclude (&source, ChsrcTypeAuto);
} }

View File

@ -27,7 +27,7 @@ def_sources_n(pl_nodejs_pnpm);
void void
pl_nodejs_pnpm_getsrc (char *option) pl_nodejs_pnpm_getsrc (char *option)
{ {
chsrc_run ("pnpm config get registry", RunOpt_Default); chsrc_run ("pnpm config get registry", RunOpt_No_Last_New_Line);
} }
@ -49,7 +49,7 @@ pl_nodejs_pnpm_setsrc (char *option)
else else
cmd = xy_2strjoin ("pnpm config -g set registry ", source.url); cmd = xy_2strjoin ("pnpm config -g set registry ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_conclude (&source, ChsrcTypeAuto); chsrc_conclude (&source, ChsrcTypeAuto);
} }