feat: 优化 CLI 工具配置管理,动态加载工具并简化配置路径

This commit is contained in:
catlog22
2026-01-11 20:40:51 +08:00
parent 9d7b77059f
commit e1eafede65
6 changed files with 134 additions and 78 deletions

View File

@@ -10,8 +10,12 @@ const WINDOWS_METACHARS = /[&|<>()%!"]/g;
export function escapeWindowsArg(arg: string): string {
if (arg === '') return '""';
// Normalize newlines to spaces to prevent cmd.exe from
// misinterpreting multiline arguments (breaks argument parsing)
let sanitizedArg = arg.replace(/\r?\n/g, ' ');
// Escape caret first to avoid double-escaping when prefixing other metachars.
let escaped = arg.replace(/\^/g, '^^');
let escaped = sanitizedArg.replace(/\^/g, '^^');
// Escape cmd.exe metacharacters with caret.
escaped = escaped.replace(WINDOWS_METACHARS, '^$&');