Skip to content

TagSpaces is an offline, open source, document manager with tagging support

stop chokidar in production

sytolk5e85c2f4e37c
diff --git a/src/main/chokidarWatcher.ts b/src/main/chokidarWatcher.ts
index 6f70c16d0..f0c93dca8 100644
--- a/src/main/chokidarWatcher.ts
+++ b/src/main/chokidarWatcher.ts
@@ -1,5 +1,6 @@
import { BrowserWindow } from 'electron';
import Chokidar = require('chokidar');
+import prcs from 'process';
let watcher;
@@ -29,56 +30,28 @@ export function watchFolder(
depth,
) {
console.log('Start watching: ' + path);
- stopWatching();
- watcher = Chokidar.watch(path, {
- ignored: (
- path, //, stats) =>
- ) =>
- (/(^|[\/\\])\../.test(path) && !path.includes('.ts')) || // ignoring .dotfiles but not dirs like .ts
- (path.includes('.ts') && path.includes('tsi.json')), // ignoring .ts/tsi.json folder
- // /(^|[\/\\])\../.test(path) || path.includes('.ts'), // ignoring .dotfiles // ignoring .ts folder
- // (stats && stats.isDirectory()), // ignoring directories
- ignoreInitial: true,
- depth,
- });
+ if (prcs.env.NODE_ENV === 'development') {
+ // TODO chokidar do not work in package https://github.com/electron/forge/issues/2594
+ stopWatching();
+ watcher = Chokidar.watch(path, {
+ ignored: (
+ path, //, stats) =>
+ ) =>
+ (/(^|[\/\\])\../.test(path) && !path.includes('.ts')) || // ignoring .dotfiles but not dirs like .ts
+ (path.includes('.ts') && path.includes('tsi.json')), // ignoring .ts/tsi.json folder
+ // /(^|[\/\\])\../.test(path) || path.includes('.ts'), // ignoring .dotfiles // ignoring .ts folder
+ // (stats && stats.isDirectory()), // ignoring directories
+ ignoreInitial: true,
+ depth,
+ });
- watcher.on('all', (event, path) =>
- sendMessage(mainWindow, 'folderChanged', {
- path,
- eventName: event,
- }),
- );
- /*watcher
- .on('add', (path) =>
- sendMessage(mainWindow, 'folderChanged', {
- path,
- eventName: 'add',
- }),
- )
- .on('change', (path) =>
+ watcher.on('all', (event, path) =>
sendMessage(mainWindow, 'folderChanged', {
path,
- eventName: 'change',
+ eventName: event,
}),
- )
- .on('unlink', (path) =>
- sendMessage(mainWindow, 'folderChanged', {
- path,
- eventName: 'unlink',
- }),
- )
- .on('addDir', (path) =>
- sendMessage(mainWindow, 'folderChanged', {
- path,
- eventName: 'addDir',
- }),
- )
- .on('unlinkDir', (path) =>
- sendMessage(mainWindow, 'folderChanged', {
- path,
- eventName: 'unlinkDir',
- }),
- );*/
+ );
+ }
}
/*export function watchFile(