I am trying to run a check within a folder that will display only one alert if there is any other file than extension - '.txt'
Here is my code:
for (let file of files) {
const ext = path.extname(file);
console.log(typeof file)
if (ext != '.txt') {
console.log(ext)
console.log("The error should have popped up")
dialog.showErrorBox('Non TXT file detected', 'there is a non-txt file in the folder')
break
}
else {
console.log("Not Working")
}
}
The issue that I am having is that say there were 10 ".txt" files in the folder, if I renamed one of them to ".test" I would receive 10 alerts. Is there a way to as soon as the "dialog.showErrorBox" has been called prevent to for loop for continuing.
I receive the same amount of errors no matter which file i change the extension for.