8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/themebox/cli.rb', line 8
def watch
token = File.read(File.expand_path("~/.themebox")).strip
themebox = ::Themebox::Client.new(token)
basepath = Pathname.new( File.expand_path('.') )
puts "Listening to #{basepath}"
listener = Listen.to('.') do |modified, added, removed|
changed = modified + added + removed
changed.each do |absolute_path|
relative_path = Pathname.new(absolute_path).relative_path_from(basepath).to_s
template_path = relative_path[/(.*)\.html\.liquid/, 1]
file = File.new(absolute_path)
themebox.upload_template(template_path, file)
end
end
sleep
end
|