change-image-suffix 2.1.4 → 2.1.5

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.5](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.4...v2.1.5) (2026-05-23)
6
+
7
+
8
+ ### Chores
9
+
10
+ * upgrade deps (sharp 0.34, TS6, @types/node 25), migrate to ESM, require node >=24 ([d3a3234](https://github.com/GuoSirius/change-image-suffix/commit/d3a323410ccd1f5ed9f04443adc25c6edd96f7df))
11
+
5
12
  ### [2.1.4](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.3...v2.1.4) (2026-05-23)
6
13
 
7
14
 
package/dist/index.js CHANGED
@@ -1,47 +1,12 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const fs = __importStar(require("fs"));
41
- const path = __importStar(require("path"));
42
- const os = __importStar(require("os"));
43
- const child_process_1 = require("child_process");
44
- const sharp_1 = __importDefault(require("sharp"));
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import * as os from 'os';
5
+ import { execSync } from 'child_process';
6
+ import { fileURLToPath } from 'url';
7
+ import sharp from 'sharp';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
45
10
  // 支持的输入/输出格式
46
11
  const SUPPORTED_INPUT_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'tif', 'webp', 'avif'];
47
12
  const SUPPORTED_OUTPUT_FORMATS = ['webp', 'jpg', 'jpeg', 'png', 'avif', 'tiff', 'tif'];
@@ -58,7 +23,7 @@ function requireWindows() {
58
23
  }
59
24
  function regDelete(key) {
60
25
  try {
61
- (0, child_process_1.execSync)(`reg delete "${key}" /f`, { stdio: 'ignore' });
26
+ execSync(`reg delete "${key}" /f`, { stdio: 'ignore' });
62
27
  }
63
28
  catch {
64
29
  // 忽略不存在的键
@@ -69,11 +34,11 @@ function installContextMenu() {
69
34
  // ── 查找 cis.cmd 路径 ──
70
35
  let cisCmd = '';
71
36
  try {
72
- cisCmd = (0, child_process_1.execSync)('where cis.cmd', { encoding: 'utf8' }).trim().split('\n')[0].trim();
37
+ cisCmd = execSync('where cis.cmd', { encoding: 'utf8' }).trim().split('\n')[0].trim();
73
38
  }
74
39
  catch {
75
40
  try {
76
- cisCmd = (0, child_process_1.execSync)('where cis', { encoding: 'utf8' }).trim().split('\n')[0].trim();
41
+ cisCmd = execSync('where cis', { encoding: 'utf8' }).trim().split('\n')[0].trim();
77
42
  }
78
43
  catch {
79
44
  console.error('❌ 找不到 cis 命令,请先执行 npm link 或 npm install -g change-image-suffix');
@@ -176,21 +141,21 @@ endlocal
176
141
  else {
177
142
  cmd = `"${cisCmd}" -t ${fmt.verb} ${menu.arg}`;
178
143
  }
179
- (0, child_process_1.execSync)(`reg add "${shellKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
180
- (0, child_process_1.execSync)(`reg add "${shellKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
144
+ execSync(`reg add "${shellKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
145
+ execSync(`reg add "${shellKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
181
146
  // 直接调用 bat,不需要 cmd /c,Windows 会自动追加文件路径
182
- (0, child_process_1.execSync)(`reg add "${shellKey}\\command" /ve /d "${cmd}" /f`, { stdio: 'ignore' });
147
+ execSync(`reg add "${shellKey}\\command" /ve /d "${cmd}" /f`, { stdio: 'ignore' });
183
148
  }
184
149
  }
185
150
  // 2. 注册主菜单项(使用 ExtendedSubCommandsKey 关联各自的子菜单)
186
151
  for (const menu of menuBases) {
187
- (0, child_process_1.execSync)(`reg add "${menu.base}" /ve /d "🖼 转换图片 (cis)" /f`, { stdio: 'ignore' });
188
- (0, child_process_1.execSync)(`reg add "${menu.base}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
189
- (0, child_process_1.execSync)(`reg add "${menu.base}" /v ExtendedSubCommandsKey /d "${menu.subMenu}" /f`, { stdio: 'ignore' });
152
+ execSync(`reg add "${menu.base}" /ve /d "🖼 转换图片 (cis)" /f`, { stdio: 'ignore' });
153
+ execSync(`reg add "${menu.base}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
154
+ execSync(`reg add "${menu.base}" /v ExtendedSubCommandsKey /d "${menu.subMenu}" /f`, { stdio: 'ignore' });
190
155
  // 使用 bat 的菜单(文件右键和目录右键):设置 command 接收文件路径 %1
191
156
  // Windows 会将父命令收到的 %1 自动传递给子命令
192
157
  if (menu.useBat) {
193
- (0, child_process_1.execSync)(`reg add "${menu.base}\\command" /ve /d "cmd /c echo %1 > nul" /f`, { stdio: 'ignore' });
158
+ execSync(`reg add "${menu.base}\\command" /ve /d "cmd /c echo %1 > nul" /f`, { stdio: 'ignore' });
194
159
  // 注意:不添加 AppliesTo 限制,让菜单始终显示
195
160
  // bat 脚本会检查文件扩展名,自动忽略非图片文件
196
161
  }
@@ -216,7 +181,7 @@ function uninstallContextMenu() {
216
181
  ];
217
182
  for (const key of mainKeys) {
218
183
  try {
219
- (0, child_process_1.execSync)(`reg delete "${key}" /f`, { stdio: 'ignore' });
184
+ execSync(`reg delete "${key}" /f`, { stdio: 'ignore' });
220
185
  }
221
186
  catch { /* ignore */ }
222
187
  }
@@ -228,7 +193,7 @@ function uninstallContextMenu() {
228
193
  ];
229
194
  for (const root of subMenuRoots) {
230
195
  try {
231
- (0, child_process_1.execSync)(`reg delete "${root}" /f`, { stdio: 'ignore' });
196
+ execSync(`reg delete "${root}" /f`, { stdio: 'ignore' });
232
197
  }
233
198
  catch { /* ignore */ }
234
199
  }
@@ -543,7 +508,7 @@ async function convertImage(inputPath, targetFormat, allInputFiles) {
543
508
  fs.copyFileSync(inputPath, outputPath);
544
509
  return { success: true, outputPath };
545
510
  }
546
- const image = (0, sharp_1.default)(inputPath);
511
+ const image = sharp(inputPath);
547
512
  switch (fmt) {
548
513
  case 'webp':
549
514
  await image.webp({ quality: 90 }).toFile(outputPath);
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "change-image-suffix",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
+ "type": "module",
4
5
  "description": "批量转换图片格式的CLI工具,支持递归搜索、深度限制、指定后缀、Windows右键菜单等功能",
5
6
  "main": "dist/index.js",
6
7
  "files": [
@@ -9,8 +10,8 @@
9
10
  "README.md",
10
11
  "LICENSE",
11
12
  "CHANGELOG.md",
12
- "scripts/postinstall.js",
13
- "scripts/preuninstall.js"
13
+ "scripts/postinstall.cjs",
14
+ "scripts/preuninstall.cjs"
14
15
  ],
15
16
  "bin": {
16
17
  "change-image-suffix": "./dist/index.js",
@@ -24,13 +25,13 @@
24
25
  "clean": "rimraf dist",
25
26
  "build": "tsc",
26
27
  "dev": "tsc --watch",
27
- "postinstall": "node scripts/postinstall.js",
28
- "preuninstall": "node scripts/preuninstall.js",
28
+ "postinstall": "node scripts/postinstall.cjs",
29
+ "preuninstall": "node scripts/preuninstall.cjs",
29
30
  "prepublishOnly": "npm run clean && npm run build",
30
- "release": "node scripts/release.js",
31
- "release:patch": "node scripts/release.js --patch",
32
- "release:minor": "node scripts/release.js --minor",
33
- "release:major": "node scripts/release.js --major",
31
+ "release": "node scripts/release.cjs",
32
+ "release:patch": "node scripts/release.cjs --patch",
33
+ "release:minor": "node scripts/release.cjs --minor",
34
+ "release:major": "node scripts/release.cjs --major",
34
35
  "lint": "tsc --noEmit",
35
36
  "typecheck": "tsc --noEmit"
36
37
  },
@@ -56,19 +57,19 @@
56
57
  },
57
58
  "homepage": "https://github.com/GuoSirius/change-image-suffix#readme",
58
59
  "dependencies": {
59
- "sharp": "^0.33.2"
60
+ "sharp": "^0.34.5"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@commitlint/cli": "^21.0.1",
63
64
  "@commitlint/config-conventional": "^21.0.1",
64
- "@types/node": "^20.11.0",
65
+ "@types/node": "^25.9.1",
65
66
  "enquirer": "^2.4.1",
66
67
  "husky": "^9.1.7",
67
68
  "rimraf": "^6.1.3",
68
69
  "standard-version": "^9.5.0",
69
- "typescript": "^5.3.3"
70
+ "typescript": "^6.0.3"
70
71
  },
71
72
  "engines": {
72
- "node": ">=16.0.0"
73
+ "node": ">=24.0.0"
73
74
  }
74
75
  }
File without changes
File without changes