项目校验脚本漂移比较忽略首尾空白

- resolve_project_verification_spec 对 actual/expected command 都做 trim,避免 package.json 脚本带首尾空格或换行时被误判成「脚本已变化」
This commit is contained in:
2026-10-07 14:04:48 +08:00
parent 2ab7717a2c
commit 3a67580956
@@ -388,7 +388,9 @@ pub(crate) fn resolve_project_verification_spec_with_cwd_at(
.and_then(|scripts| scripts.get(script))
.and_then(serde_json::Value::as_str)
.ok_or_else(|| format!("package.json 未定义 {script} 脚本"))?;
if actual_command != expected_command {
// 两边都 trim:调用方(如陶泥儿导出)给出的 expectedCommand 来自剥离空白后的脚本值,
// 而 package.json 里可能带首尾空格/换行;只按原始值比较会把「空白差异」误判成脚本漂移。
if actual_command.trim() != expected_command.trim() {
return Err(format!(
"package.json 中的 {script} 脚本已变化,请重新读取后再确认执行"
));