forked from howl-editor/howl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spookfile
72 lines (58 loc) · 1.92 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- These helpers come built-in but must
-- be required for use.
{
:until_success
:command
:task_filter
:notifies
} = require 'spookfile_helpers'
fs = require 'fs'
{:notify, :load_spookfile} = _G
log_level "INFO"
-- This notifier is built-in.
notify.add 'terminal_notifier'
-- Add whatever other notifier you like,
-- just make sure it's in the package path.
-- Do note that notifiers are slightly
-- different in 0.7.x from 0.6.x.
pcall notify.add, 'notifier'
-- Filters tasks on whether the mapped
-- file is present (eg. won't run unless it is)
task_list = task_filter fs.is_present
-- Setup some commands, eg. wrap commands
-- that can later be called with a path as
-- input.
lint = command "./bin/howl-lint"
spec = command "./bin/howl-spec"
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 "lib", "spec", ->
on_changed "_spec%.moon", (event) ->
run_spec event.path\match('(.+_spec%.moon)$'), event
on_changed "^lib/howl/.+%.moon$", (event) ->
base = event.path\match '^lib/howl/(.*)%.moon'
run_spec "spec/#{base}_spec.moon", event
on_changed "^lib/aullar/.+%.moon", (event) ->
base = event.path\match('^lib/aullar/(.*)%.moon')
run_spec "lib/aullar/spec/#{base}_spec.moon", event
on_changed "^lib/ljglibs/.+%.moon", (event) ->
base = event.path\match('^lib/ljglibs/(.*)%.moon')
run_spec "lib/ljglibs/spec/#{base}_spec.moon", event
watch "bundles", ->
on_changed "^(.+_spec%.moon)", (event) ->
base = event.path\match('^(.+_spec%.moon)')
run_spec base, event
on_changed "%.moon$", (event) ->
dir, base = event.path\match('^(.+)/(.+)%.moon')
unless base\find '_spec'
run_spec "#{dir}/spec/#{base}_spec.moon", event
watch_file 'Spookfile', ->
on_changed (event) ->
notify.info "Reloading Spookfile..."
load_spookfile!