mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-08-03 06:17:36 +08:00
refactor: Improve Cursor file modification validation and logging
- Enhanced file content validation with more flexible regex matching for crypto.randomUUID() - Added debug logging to preview file contents during validation - Improved error detection and logging for file modification process - Maintained existing script modification strategy with more robust validation
This commit is contained in:
parent
d8810042f1
commit
d86701fd94
@ -278,12 +278,17 @@ modify_cursor_app_files() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 验证文件内容是否包含必要的代码
|
# 验证文件内容是否包含必要的代码
|
||||||
if ! grep -q "crypto.randomUUID()" "$temp_file"; then
|
log_debug "正在验证文件内容..."
|
||||||
|
if ! grep -q "crypto\s*\.\s*randomUUID\s*(" "$temp_file"; then
|
||||||
|
log_debug "文件内容预览:"
|
||||||
|
head -n 20 "$temp_file" | log_debug
|
||||||
log_error "修改后的文件缺少必要的代码: $file"
|
log_error "修改后的文件缺少必要的代码: $file"
|
||||||
rm -f "$temp_file"
|
rm -f "$temp_file"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log_debug "文件验证通过"
|
||||||
|
|
||||||
# 替换原文件
|
# 替换原文件
|
||||||
if ! mv "$temp_file" "$file"; then
|
if ! mv "$temp_file" "$file"; then
|
||||||
log_error "无法更新文件: $file"
|
log_error "无法更新文件: $file"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user