change-image-suffix 2.1.16 → 2.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.1.17](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.16...v2.1.17) (2026-05-25)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * use .reg file instead of reg add to avoid cmd.exe quote mangling ([142f410](https://github.com/GuoSirius/change-image-suffix/commit/142f4107f32b8615080018a9c5ec908bb950ac1b))
11
+
5
12
  ### [2.1.16](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.15...v2.1.16) (2026-05-25)
6
13
 
7
14
 
package/dist/index.js CHANGED
@@ -73,17 +73,29 @@ function installContextMenu() {
73
73
  { base: 'HKCU\\Software\\Classes\\Directory\\Background\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis', arg: '-p "%V"' },
74
74
  { base: 'HKCU\\Software\\Classes\\AllFilesystemObjects\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_afo', arg: '"%1"', multiSelect: true },
75
75
  ];
76
- // 1. 注册格式子菜单
77
- const REG_ROOT = 'HKCU\\Software\\Classes\\';
76
+ // 1. 用 .reg 文件写子菜单(避免 cmd.exe 引号嵌套解析出错)
77
+ const regLines = ['Windows Registry Editor Version 5.00', ''];
78
78
  for (const menu of menuBases) {
79
79
  for (const fmt of formats) {
80
- const shellKey = `${REG_ROOT}${menu.subMenu}\\shell\\${fmt.verb}`;
80
+ // .reg 语法:值内 \" → 引号,\\ → 反斜杠,%1/%V 保持原样
81
81
  const cmd = `"${nodeExe}" "${scriptPath}" --pause -t ${fmt.verb} ${menu.arg}`;
82
- execSync(`reg add "${shellKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
83
- execSync(`reg add "${shellKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
84
- execSync(`reg add "${shellKey}\\command" /ve /d "${cmd}" /f`, { stdio: 'ignore' });
82
+ const cmdEscaped = cmd.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
83
+ const key = `HKEY_CURRENT_USER\\Software\\Classes\\${menu.subMenu}\\shell\\${fmt.verb}`;
84
+ regLines.push(`[${key}]`);
85
+ regLines.push(`@="${fmt.label}"`);
86
+ regLines.push(`"Icon"="${iconPath.replace(/\\/g, '\\\\')}"`);
87
+ regLines.push(`[${key}\\command]`);
88
+ regLines.push(`@="${cmdEscaped}"`);
89
+ regLines.push('');
85
90
  }
86
91
  }
92
+ const regFile = path.join(appDataDir, 'cis_menu.reg');
93
+ fs.writeFileSync(regFile, regLines.join('\r\n'), 'utf8');
94
+ execSync(`reg import "${regFile}"`, { stdio: 'ignore' });
95
+ try {
96
+ fs.unlinkSync(regFile);
97
+ }
98
+ catch { /* ignore */ }
87
99
  // 2. 注册主菜单项
88
100
  for (const menu of menuBases) {
89
101
  execSync(`reg add "${menu.base}" /ve /d "🖼 转换图片 (cis)" /f`, { stdio: 'ignore' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "change-image-suffix",
3
- "version": "2.1.16",
3
+ "version": "2.1.17",
4
4
  "type": "module",
5
5
  "description": "批量转换图片格式的CLI工具,支持递归搜索、深度限制、指定后缀、Windows右键菜单等功能",
6
6
  "main": "dist/index.js",