change-image-suffix 2.1.13 → 2.1.14

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.14](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.13...v2.1.14) (2026-05-25)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add quotes around %V/%1 in context menu, make resolveSplitPath return string[] ([28ccc83](https://github.com/GuoSirius/change-image-suffix/commit/28ccc83d39f4441eac31a8985509ac49a8ab7019))
11
+
5
12
  ### [2.1.13](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.12...v2.1.13) (2026-05-25)
6
13
 
7
14
 
package/dist/index.js CHANGED
@@ -69,9 +69,9 @@ function installContextMenu() {
69
69
  ];
70
70
  // ── 使用 ExtendedSubCommandsKey,直接调用 node.exe(无 bat 中转)──
71
71
  const menuBases = [
72
- { base: 'HKCU\\Software\\Classes\\Directory\\Background\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis', arg: '-p %V' },
73
- { base: 'HKCU\\Software\\Classes\\Directory\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_dir', arg: '-p %1' },
74
- { base: 'HKCU\\Software\\Classes\\*\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_file', arg: '-f %1' },
72
+ { base: 'HKCU\\Software\\Classes\\Directory\\Background\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis', arg: '-p "%V"' },
73
+ { base: 'HKCU\\Software\\Classes\\Directory\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_dir', arg: '-p "%1"' },
74
+ { base: 'HKCU\\Software\\Classes\\*\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_file', arg: '-f "%1"' },
75
75
  ];
76
76
  // 1. 注册格式子菜单
77
77
  const REG_ROOT = 'HKCU\\Software\\Classes\\';
@@ -127,13 +127,13 @@ function uninstallContextMenu() {
127
127
  }
128
128
  catch { /* ignore */ }
129
129
  }
130
- // 删除批处理文件、图标和版本标记
130
+ // 删除遗留文件(旧版 bat 脚本、图标、版本标记)
131
131
  const appDataDir = path.join(os.homedir(), 'AppData', 'Roaming', 'change-image-suffix');
132
132
  const batPath = path.join(appDataDir, 'cis_file.bat');
133
133
  try {
134
134
  fs.unlinkSync(batPath);
135
135
  }
136
- catch { /* ignore */ }
136
+ catch { /* ignore */ } // 旧版残留清理
137
137
  const iconPath = path.join(appDataDir, 'icon.ico');
138
138
  try {
139
139
  fs.unlinkSync(iconPath);
@@ -183,19 +183,13 @@ function autoUpdateContextMenu() {
183
183
  // 此函数尝试将拆散的片段拼接回完整路径。
184
184
  function resolveSplitPath(parts) {
185
185
  if (parts.length === 1)
186
- return path.resolve(parts[0]);
187
- // 如果首段已存在,说明不是拆分导致的多段(用户主动传了多个路径)
188
- if (fs.existsSync(parts[0]))
189
- return path.resolve(parts[0]);
190
- // 逐段拼接,直到找到存在的路径
191
- let joined = parts[0];
192
- for (let j = 1; j < parts.length; j++) {
193
- joined += ' ' + parts[j];
194
- if (fs.existsSync(joined))
195
- return path.resolve(joined);
196
- }
197
- // 都不存在,返回全拼接结果(后续流程会报 "不存在")
198
- return path.resolve(joined);
186
+ return [path.resolve(parts[0])];
187
+ // 尝试将拆散的片段用空格拼接回完整路径(右键菜单可能将含空格的路径拆成多段)
188
+ const fullJoin = parts.join(' ');
189
+ if (fs.existsSync(fullJoin))
190
+ return [path.resolve(fullJoin)];
191
+ // 无法拼接为单个存在的路径 各段视为独立路径(用户主动传了多个路径)
192
+ return parts.map(p => path.resolve(p));
199
193
  }
200
194
  function parseArgs() {
201
195
  const args = process.argv.slice(2);
@@ -278,7 +272,7 @@ function parseArgs() {
278
272
  dirsFromFlag.push(path.resolve('.'));
279
273
  }
280
274
  else {
281
- dirsFromFlag.push(resolveSplitPath(parts));
275
+ dirsFromFlag.push(...resolveSplitPath(parts));
282
276
  }
283
277
  i++;
284
278
  continue;
@@ -294,7 +288,7 @@ function parseArgs() {
294
288
  console.error('❌ -f/--file 需要指定至少一个文件路径');
295
289
  process.exit(1);
296
290
  }
297
- filesFromFlag.push(resolveSplitPath(parts));
291
+ filesFromFlag.push(...resolveSplitPath(parts));
298
292
  i++;
299
293
  continue;
300
294
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "change-image-suffix",
3
- "version": "2.1.13",
3
+ "version": "2.1.14",
4
4
  "type": "module",
5
5
  "description": "批量转换图片格式的CLI工具,支持递归搜索、深度限制、指定后缀、Windows右键菜单等功能",
6
6
  "main": "dist/index.js",