-
Notifications
You must be signed in to change notification settings - Fork 7
/
Spookfile
50 lines (39 loc) · 1.11 KB
/
Spookfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
:until_success
:command
:task_filter
:notifies
} = require 'spookfile_helpers'
{:is_file, :is_present} = require "fs"
-- builtin notifier
notify.add 'terminal_notifier'
-- user notifiers
pcall notify.add, 'notifier'
log_level "INFO"
lint = command "moonpick"
spec = command "busted"
compile = command "moonc"
-- Filters tasks on whether the mapped
-- file is present (eg. won't run unless it is)
task_list = task_filter is_present
run_spec = (path, event) ->
print "\027[1m\027[34m-> \027[22m(#{path}..)\027[0m"
until_success ->
notifies path, event,
task_list(
spec, path,
lint, event.path
)
watch "src", "spec", ->
on_changed "^spec/.+_spec%.moon", (event) ->
run_spec event.path, event
on_changed "^src/moonpick/.+%.moon", (event) ->
base = event.path\match '([^/]+)%.moon'
spec_file = "spec/#{base}_spec.moon"
spec_file = "spec/moonpick_spec.moon" unless is_file(spec_file)
compile("src/moonpick/#{base}.moon") +
run_spec(spec_file, event)
watch_file 'Spookfile', ->
on_changed (event) ->
notify.info "Reloading Spookfile..."
load_spookfile!