From 2575cf6b1ae63a044cc99dc197ed0dda54a897a7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Feb 2018 13:41:17 -0800 Subject: [PATCH] Fix path duplication after decaffeinating main process code --- src/main-process/atom-window.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main-process/atom-window.js b/src/main-process/atom-window.js index 57428decd..ae6e1ccc9 100644 --- a/src/main-process/atom-window.js +++ b/src/main-process/atom-window.js @@ -154,12 +154,13 @@ class AtomWindow extends EventEmitter { containsPath (pathToCheck) { if (!pathToCheck) return false - const stat = fs.statSyncNoException(pathToCheck) - if (stat && stat.isDirectory()) return false - - return this.representedDirectoryPaths.some(projectPath => - pathToCheck === projectPath || pathToCheck.startsWith(path.join(projectPath, path.sep)) - ) + let stat + return this.representedDirectoryPaths.some(projectPath => { + if (pathToCheck === projectPath) return true + if (!pathToCheck.startsWith(path.join(projectPath, path.sep))) return false + if (stat === undefined) stat = fs.statSyncNoException(pathToCheck) + return !stat || !stat.isDirectory() + }) } handleEvents () {