Răsfoiți Sursa

fix: ignored path

Tienson Qin 4 ani în urmă
părinte
comite
205b1711bb
2 a modificat fișierele cu 11 adăugiri și 9 ștergeri
  1. 2 1
      src/electron/electron/fs_watcher.cljs
  2. 9 8
      src/electron/electron/utils.cljs

+ 2 - 1
src/electron/electron/fs_watcher.cljs

@@ -23,7 +23,8 @@
   (when (fs/existsSync dir)
     (let [watcher (.watch watcher dir
                           (clj->js
-                           {:ignored (partial utils/ignored-path? dir)
+                           {:ignored (fn [path]
+                                       (utils/ignored-path? dir path))
                             :ignoreInitial true
                             :ignorePermissionErrors true
                             :interval polling-interval

+ 9 - 8
src/electron/electron/utils.cljs

@@ -1,6 +1,8 @@
 (ns electron.utils
   (:require [clojure.string :as string]
-            ["fs" :as fs]))
+            ["fs" :as fs]
+            ["path" :as path]
+            [clojure.string :as string]))
 
 (defonce mac? (= (.-platform js/process) "darwin"))
 (defonce win32? (= (.-platform js/process) "win32"))
@@ -13,10 +15,6 @@
 (defonce open (js/require "open"))
 (defonce fetch (js/require "node-fetch"))
 
-(defn get-file-ext
-  [file]
-  (last (string/split file #"\.")))
-
 (defn ignored-path?
   [dir path]
   (when (string? path)
@@ -25,13 +23,16 @@
            ["." ".recycle" "assets" "node_modules"])
      (some #(string/includes? path (str "/" % "/"))
            ["." ".recycle" "assets" "node_modules"])
+     (string/ends-with? path ".DS_Store")
      ;; hidden directory or file
      (re-find #"/\.[^.]+" path)
      (re-find #"^\.[^.]+" path)
      (let [path (string/lower-case path)]
-       (not
-        (some #(string/ends-with? path %)
-              [".md" ".markdown" ".org" ".edn" ".css"]))))))
+       (and
+        (not (string/blank? (path/extname path)))
+        (not
+         (some #(string/ends-with? path %)
+               [".md" ".markdown" ".org" ".edn" ".css"])))))))
 
 (defn fix-win-path!
   [path]