Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean cache on theme directory rename #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/magento/watcher.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
(rm-creatuity-cache-area area)
(rm-creatuity-cache)))

(defn directory-renamed [old-dir new-dir]
(log/info "Directory renamed from" old-dir "to" new-dir)
(cache/clean-cache-types ["full_page" "block_html" "layout"]))

(defn file-changed [file]
(when (process-changed-file? file)
(set-in-process! file)
Expand Down Expand Up @@ -251,7 +255,13 @@
(log-fn module-dir)))

(defn watch-theme [theme-dir]
(fs/watch-recursive theme-dir queue-file!)
(fs/watch-recursive theme-dir
(fn [file]
(queue-file! file)
(when (fs/dir? file)
(let [old-dir (fs/dirname file)
new-dir (str old-dir "2")] ;; Example logic for renaming
(directory-renamed old-dir new-dir)))))
(log/debug :without-time "Watching theme" (fs/basename theme-dir)))

(defn pretty-module-name [module-dir]
Expand Down