Skip to content

Commit 9962cf7

Browse files
committed
Improve eca_edit_file to check for path existence
1 parent dc62d53 commit 9962cf7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/eca/features/tools.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
[eca.features.tools.util :as tools.util]
1111
[eca.logger :as logger]
1212
[eca.messenger :as messenger]
13-
[eca.shared :refer [assoc-some]])
13+
[eca.shared :refer [assoc-some]]
14+
[babashka.fs :as fs])
1415
(:import
1516
[java.util Map]))
1617

@@ -131,7 +132,7 @@
131132
new-content (get arguments "new_content")
132133
all? (get arguments "all_occurrences")]
133134
(when-let [{:keys [original-full-content
134-
new-full-content]} (and path original-content new-content
135+
new-full-content]} (and path (fs/exists? path) original-content new-content
135136
(f.tools.filesystem/file-change-full-content path original-content new-content all?))]
136137
(let [{:keys [added removed diff]} (diff/diff original-full-content new-full-content path)]
137138
{:type :fileChange

0 commit comments

Comments
 (0)