fix: avoid ENOTDIR when opening second instance.

If the resource is a file, do not try to `readdir`, but return undefined

Closes #1590

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-11-02 16:36:56 +01:00 committed by Akos Kitta
parent 7d6a2d5e33
commit c3dc7c6307

View File

@ -181,8 +181,8 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
if (!stats) {
return undefined;
}
if (stats.isFile() && path.endsWith('.ino')) {
return path;
if (stats.isFile()) {
return path.endsWith('.ino') ? path : undefined;
}
try {
const entries = await fs.readdir(path, { withFileTypes: true });