auto-image-converter 1.1.12 → 1.1.13

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 +12 -5
  2. package/package.json +1 -1
package/bin/watcher.mjs CHANGED
@@ -10,14 +10,21 @@ const config = (await import(pathToFileURL(configPath).href)).default;
10
10
  const watchDir = config.dir || "public";
11
11
  const absWatchDir = path.resolve(process.cwd(), watchDir);
12
12
 
13
- // В chokidar нужно передавать glob с POSIX слэшами
14
- const baseDirPosix = absWatchDir.split(path.sep).join(path.posix.sep);
15
- const watchPath = `${baseDirPosix}/**/*.{png,jpg,jpeg}`;
13
+ // Для chokidar лучше передать просто папку, а не glob
14
+ const watchPath = absWatchDir;
16
15
 
17
- console.log(`👀 Watching for image changes on: ${watchPath}`);
16
+ console.log(`👀 Watching for image changes on directory: ${watchPath}`);
18
17
 
19
18
  chokidar
20
- .watch(watchPath, { ignoreInitial: true })
19
+ .watch(watchPath, {
20
+ ignored: /(^|[\/\\])\../, // игнор скрытых файлов и папок
21
+ persistent: true,
22
+ ignoreInitial: true,
23
+ awaitWriteFinish: {
24
+ stabilityThreshold: 500, // ждем, пока запись в файл закончится
25
+ pollInterval: 100,
26
+ },
27
+ })
21
28
  .on("add", async (filePath) => {
22
29
  if (/\.(png|jpe?g)$/i.test(filePath)) {
23
30
  console.log(`➕ New image: ${filePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-image-converter",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "auto-convert-images": "./bin/index.js",