forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ember_bundles.rb
49 lines (40 loc) · 1.08 KB
/
ember_bundles.rb
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
require 'guard'
require 'guard/guard'
require 'lib/ember_bundle'
module Guard
class EmberBundles < Guard
DEFAULT_OPTIONS = {
:hide_success => false,
:all_on_start => false
}
def initialize(watchers=[], options={})
super([::Guard::Watcher.new(/(app\/coffeescripts\/ember\/)/)], {})
end
def start
run_all if options[:all_on_start]
end
def run_on_change(paths)
build_bundles(paths)
end
def build_bundles(paths)
paths.each do |path|
return if path.match(/main\.coffee$/)
begin
UI.info "Building ember bundle for: #{path}"
EmberBundle::build_from_file(path)
rescue Exception => e
::Guard::Notifier.notify(e.to_s, :title => path, :image => :failed)
end
end
end
def run_all
UI.info "Building all ember bundles"
Dir.entries('app/coffeescripts/ember').reject {|d| d.match(/^\./) || d == 'shared'}.each do |app|
EmberBundle.new(app).build
end
end
def run_on_deletion(paths)
build_bundles(paths)
end
end
end