class FileChecker {
constructor() {
this.arguments = process.argv.splice(2);
this.fileToCheck = this.arguments[0];
this.directoryToSearch = this.arguments[1] ? this.arguments[1] : '';
this.currentDirectory = process.cwd();
this.finalDestination = `${this.currentDirectory}\\` + this.directoryToSearch;
//Issue Area
if(this.checkIfFileExists(this.fileToCheck, this.finalDestination)) console.log("FILE EXISTS")
else console.log("FILE DOES NOT EXIST");
}
async checkIfFileExists(file, directory) {
try {
let files = await fs.readdir(directory);
return files.includes(file);
} catch(error) {
console.log("Error: ", error)
return false;
}
}
}
I am attempting to verify the presence of a file in a directory using promises for file system operations. However, the problematic section consistently returns true, and I am running low on solutions.