auto-image-converter 1.1.11 → 1.1.12

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.
Files changed (2) hide show
  1. package/bin/watcher.mjs +16 -7
  2. package/package.json +1 -1
package/bin/watcher.mjs CHANGED
@@ -9,13 +9,22 @@ const config = (await import(pathToFileURL(configPath).href)).default;
9
9
 
10
10
  const watchDir = config.dir || "public";
11
11
  const absWatchDir = path.resolve(process.cwd(), watchDir);
12
- const watchPath = path.join(absWatchDir, "**", "*.{png,jpg,jpeg}");
12
+
13
+ // В chokidar нужно передавать glob с POSIX слэшами
14
+ const baseDirPosix = absWatchDir.split(path.sep).join(path.posix.sep);
15
+ const watchPath = `${baseDirPosix}/**/*.{png,jpg,jpeg}`;
13
16
 
14
17
  console.log(`👀 Watching for image changes on: ${watchPath}`);
15
18
 
16
- chokidar.watch(baseDirPosix, { ignoreInitial: true }).on("add", (filePath) => {
17
- if (/\.(png|jpe?g)$/i.test(filePath)) {
18
- console.log(`➕ New image: ${filePath}`);
19
- // ...
20
- }
21
- });
19
+ chokidar
20
+ .watch(watchPath, { ignoreInitial: true })
21
+ .on("add", async (filePath) => {
22
+ if (/\.(png|jpe?g)$/i.test(filePath)) {
23
+ console.log(`➕ New image: ${filePath}`);
24
+ try {
25
+ await convertImages(config);
26
+ } catch (err) {
27
+ console.error("Ошибка при конвертации:", err.message);
28
+ }
29
+ }
30
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-image-converter",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "auto-convert-images": "./bin/index.js",