Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ priv/templates/*.erl
rebar.lock
*.backup
*.bak
compile_commands.json
rebar3.crashdump
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PROJECT = docs
ROOT_DIR = $(shell pwd)
REPO = $(shell git config --get remote.origin.url)
LFE = _build/dev/lib/lfe/bin/lfe
ERL_LIBS = $(shell find ./_build/*/lib -maxdepth 1 -mindepth 1 -exec printf "%s:" {} \;)
ERL_LIBS = $(shell find ./_build/*/* -maxdepth 1 -mindepth 1 -exec printf "%s:" {} \;)
RIGHT_PAREN = )
LOCAL_DOCS_HOST = $(subst $(RIGHT_PAREN),,$(strip $(lastword $(shell grep host lfe.config))))
LOCAL_DOCS_PORT = $(subst $(RIGHT_PAREN),,$(strip $(lastword $(shell grep port lfe.config))))
Expand Down
3 changes: 2 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
{dev, [
{deps, [
{lfe, {git, "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/rvirding/lfe.git", {branch, "develop"}}},
{barista, {git, "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/lfe-mug/barista.git", {tag, "0.2.2"}}}
{barista, {git, "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/lfe-mug/barista.git", {tag, "0.2.2"}}},
{inotify, {git, "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/erlsci/inotify.git", {tag, "v0.5.0"}}}
]},
{plugins, [
{'lfe-version', {git, "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/lfe-rebar3/version.git", {tag, "0.5.0-rc2"}}},
Expand Down
37 changes: 37 additions & 0 deletions src/docs-watcher.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(defmodule docs-watcher
(export all))

(defun default-watch-data ()
`(#("priv/templates" ,#'erlydtl-watcher/1)
#("src" ,#'lfe-watcher/1)))

(defun lfe-compiler (filename)
(logjam:info "Recompiling LFE file: ~p" `(,filename)))

(defun erlydtl-compiler (filename)
(logjam:info "Recompiling ErlyDTL file: ~p" `(,filename)))

(defun lfe-watcher
((`#(,path file close_write ,fd ,file))
(lfe-compiler (filename:join path file)))
((_arg)
'skipping))

(defun erlydtl-watcher
((`#(,path file close_write ,fd ,file))
(erlydtl-compiler (filename:join path file)))
((_) 'skipping))

(defun start ()
(start (default-watch-data)))

(defun start (watch-data)
(logjam:start)
(application:ensure_all_started 'inotify)
(case (lists:map (match-lambda ((`#(,path ,func))
(logjam:debug "Watching path: ~p with function: ~p"
`(,path ,func))
(inotify:watch path func)))
watch-data)
('(ok ok) 'ok)
(err (logjam:error err))))