From 8130f11cd1b9297b859dad4e9ae92a00d03b2465 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 22 Aug 2025 13:38:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Python=20=E5=92=8C=20JavaS?= =?UTF-8?q?cript=20=E7=BB=84=E4=B8=AD=20target=20=E7=9A=84=20`ls`=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/core.c | 8 ++++++++ src/recipe/lang/JavaScript/Bun.c | 4 +--- src/recipe/lang/JavaScript/Yarn.c | 4 +--- src/recipe/lang/JavaScript/npm.c | 4 +--- src/recipe/lang/JavaScript/nvm.c | 4 +--- src/recipe/lang/JavaScript/pnpm.c | 4 +--- src/recipe/lang/Python/Poetry.c | 4 +--- src/recipe/lang/Python/Rye.c | 4 +--- src/recipe/lang/Python/pip.c | 4 +--- src/recipe/lang/Python/uv.c | 4 +--- 10 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/framework/core.c b/src/framework/core.c index d2b90b1..4c7ed0a 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -1023,6 +1023,14 @@ source_has_empty_url (Source_t *source) Source_t chsrc_yield_source (Target_t *t, char *option) { + /** + * 防止某些意外时刻 _setsrc() 等函数会被直接调,但此时 _prelude() 还没有执行过 + * 我们在这里卡一道,确保 _prelude() 被调用 + * + * 目前可能出现这种情况的时候:组换源的时候,组成菜的 _setsrc() 被直接调用 + */ + if (!t->inited) t->preludefn(); + Source_t source; if (chsrc_in_target_group_mode() && ProgStatus.leader_selected_index==-1) { diff --git a/src/recipe/lang/JavaScript/Bun.c b/src/recipe/lang/JavaScript/Bun.c index 6bcdff0..ebd8a16 100644 --- a/src/recipe/lang/JavaScript/Bun.c +++ b/src/recipe/lang/JavaScript/Bun.c @@ -21,9 +21,7 @@ pl_js_bun_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 用的是 npm Registry 的源,所以使用 pl_js_group 的源 - this->sources = pl_js_group_target.sources; - this->sources_n = pl_js_group_target.sources_n; + chef_use_other_target_sources (this, &pl_js_group_target); } /** diff --git a/src/recipe/lang/JavaScript/Yarn.c b/src/recipe/lang/JavaScript/Yarn.c index 62d06fc..65532ae 100644 --- a/src/recipe/lang/JavaScript/Yarn.c +++ b/src/recipe/lang/JavaScript/Yarn.c @@ -21,9 +21,7 @@ pl_js_yarn_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_js_group 的源 - this->sources = pl_js_group_target.sources; - this->sources_n = pl_js_group_target.sources_n; + chef_use_other_target_sources (this, &pl_js_group_target); } static double diff --git a/src/recipe/lang/JavaScript/npm.c b/src/recipe/lang/JavaScript/npm.c index d40477b..ff832e4 100644 --- a/src/recipe/lang/JavaScript/npm.c +++ b/src/recipe/lang/JavaScript/npm.c @@ -21,9 +21,7 @@ pl_js_npm_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_js_group 的源 - this->sources = pl_js_group_target.sources; - this->sources_n = pl_js_group_target.sources_n; + chef_use_other_target_sources (this, &pl_js_group_target); } diff --git a/src/recipe/lang/JavaScript/nvm.c b/src/recipe/lang/JavaScript/nvm.c index 5ae2206..cc65e1b 100644 --- a/src/recipe/lang/JavaScript/nvm.c +++ b/src/recipe/lang/JavaScript/nvm.c @@ -23,9 +23,7 @@ pl_js_nvm_prelude (void) chef_set_note (this, "nvm 不支持 Fish shell", "nvm does not support Fish"); - // 使用 pl_js_nodejs_binary 的源 - this->sources = pl_js_nodejs_binary_target.sources; - this->sources_n = pl_js_nodejs_binary_target.sources_n; + chef_use_other_target_sources (this, &pl_js_nodejs_binary_target); } diff --git a/src/recipe/lang/JavaScript/pnpm.c b/src/recipe/lang/JavaScript/pnpm.c index 847b1d9..40b8694 100644 --- a/src/recipe/lang/JavaScript/pnpm.c +++ b/src/recipe/lang/JavaScript/pnpm.c @@ -21,9 +21,7 @@ pl_js_pnpm_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_js_group 的源 - this->sources = pl_js_group_target.sources; - this->sources_n = pl_js_group_target.sources_n; + chef_use_other_target_sources (this, &pl_js_group_target); } diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c index 7d2008b..24e185a 100644 --- a/src/recipe/lang/Python/Poetry.c +++ b/src/recipe/lang/Python/Poetry.c @@ -21,9 +21,7 @@ pl_python_poetry_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_python_group 的源 - this->sources = pl_python_group_target.sources; - this->sources_n = pl_python_group_target.sources_n; + chef_use_other_target_sources (this, &pl_python_group_target); } void diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index d1472e2..10ea91c 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -23,9 +23,7 @@ pl_python_rye_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_python_group 的源 - this->sources = pl_python_group_target.sources; - this->sources_n = pl_python_group_target.sources_n; + chef_use_other_target_sources (this, &pl_python_group_target); } char * diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index 318f712..b4a27f0 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -21,9 +21,7 @@ pl_python_pip_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_python_group 的源 - this->sources = pl_python_group_target.sources; - this->sources_n = pl_python_group_target.sources_n; + chef_use_other_target_sources (this, &pl_python_group_target); } diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index f2f89e8..f56d9fe 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -21,9 +21,7 @@ pl_python_uv_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - // 使用 pl_python_group 的源 - this->sources = pl_python_group_target.sources; - this->sources_n = pl_python_group_target.sources_n; + chef_use_other_target_sources (this, &pl_python_group_target); }