fix: 修复 build_tauri NSIS 模板替换报 bad escape
re.subn 替换字符串含 Windows 路径反斜杠被当成正则转义(\c);改用函数返回字面量。
This commit is contained in:
@@ -17,6 +17,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -113,12 +114,11 @@ def make_nsis_template(tmp_dir: Path) -> Path:
|
||||
source = find_nsis_template()
|
||||
content = source.read_text(encoding="utf-8")
|
||||
|
||||
import re
|
||||
|
||||
hook_path = str(NSIS_HOOK.resolve())
|
||||
include_line = f'!include "{hook_path}"'
|
||||
content, n = re.subn(
|
||||
r'\{\{#if installer_hooks\}\}\s*!include "\{\{installer_hooks\}\}"\s*\{\{/if\}\}',
|
||||
f'!include "{hook_path}"',
|
||||
lambda _: include_line,
|
||||
content,
|
||||
)
|
||||
if n == 0:
|
||||
|
||||
Reference in New Issue
Block a user