Refactor watcher logic to ignore empty or relative paths
This commit is contained in:
2
main.js
2
main.js
@@ -472,6 +472,7 @@ async function startMonitoringWatcher(folderPath, win) {
|
|||||||
|
|
||||||
// Relativer Pfad zum Repo
|
// Relativer Pfad zum Repo
|
||||||
const rel = path.relative(folderPath, filePath);
|
const rel = path.relative(folderPath, filePath);
|
||||||
|
if (!rel || rel === '' || rel === '.') return true;
|
||||||
// 1) Wenn die Datei in der .gitignore steht → ignorieren
|
// 1) Wenn die Datei in der .gitignore steht → ignorieren
|
||||||
if (igFilter.ignores(rel)) return true;
|
if (igFilter.ignores(rel)) return true;
|
||||||
// 2) Ansonsten wird die Änderung durch unseren Code ohnehin
|
// 2) Ansonsten wird die Änderung durch unseren Code ohnehin
|
||||||
@@ -494,6 +495,7 @@ async function startMonitoringWatcher(folderPath, win) {
|
|||||||
// sonst normal doAutoCommitWithIgnoreCheck() aufrufen.
|
// sonst normal doAutoCommitWithIgnoreCheck() aufrufen.
|
||||||
watcher.on('all', async (event, filePathAbsolute) => {
|
watcher.on('all', async (event, filePathAbsolute) => {
|
||||||
const rel = path.relative(folderPath, filePathAbsolute);
|
const rel = path.relative(folderPath, filePathAbsolute);
|
||||||
|
if (!rel || rel === '' || rel === '.') return;
|
||||||
|
|
||||||
// a) Prüfe, ob dieser Pfad durch die aktuell geladene .gitignore
|
// a) Prüfe, ob dieser Pfad durch die aktuell geladene .gitignore
|
||||||
// bereits ausgeschlossen ist (z.B. node_modules/foo.js):
|
// bereits ausgeschlossen ist (z.B. node_modules/foo.js):
|
||||||
|
|||||||
Reference in New Issue
Block a user