Add folder scan & case insensitivity on ready check.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import chokidar, { FSWatcher } from "chokidar";
|
||||
import { BrowserWindow, Notification } from "electron";
|
||||
import log from "electron-log/main";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import ipcTypes from "../../util/ipcTypes.json";
|
||||
import ImportJob from "../decoder/decoder";
|
||||
import store from "../store/store";
|
||||
|
||||
let watcher: FSWatcher | null;
|
||||
|
||||
async function StartWatcher(): Promise<boolean> {
|
||||
@@ -136,10 +136,31 @@ async function HandleNewFile(path): Promise<void> {
|
||||
await ImportJob(path);
|
||||
}
|
||||
|
||||
function GetAllEnvFiles(): string[] {
|
||||
const directories = store.get("settings.filepaths") as string[];
|
||||
const files: string[] = [];
|
||||
directories.forEach((directory) => {
|
||||
try {
|
||||
const envFiles = fs
|
||||
.readdirSync(directory)
|
||||
.filter((file: string) => file.toLowerCase().endsWith(".env"));
|
||||
envFiles.forEach((file) => {
|
||||
const fullPath = path.join(directory, file);
|
||||
files.push(fullPath);
|
||||
});
|
||||
} catch (error) {
|
||||
log.error(`Failed to read directory ${directory}:`, error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
return files;
|
||||
}
|
||||
|
||||
export {
|
||||
addWatcherPath,
|
||||
GetAllEnvFiles,
|
||||
removeWatcherPath,
|
||||
StartWatcher,
|
||||
StopWatcher,
|
||||
watcher,
|
||||
removeWatcherPath,
|
||||
addWatcherPath,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user