Class: Malvolio::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/malvolio/cli.rb

Instance Method Summary collapse

Instance Method Details

#build(path = nil) ⇒ Object



19
20
21
22
23
# File 'lib/malvolio/cli.rb', line 19

def build(path = nil)
  safely do
    Malvolio::Compiler.new(path, options[:no_warnings]).run!
  end
end

#new(name) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/malvolio/cli.rb', line 9

def new(name)
  if options[:inky]
    ::Rails::Generators.invoke("malvolio:create_with_inky", [name])
  else
    ::Rails::Generators.invoke("malvolio:create", [name])
  end
end

#watch(path = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/malvolio/cli.rb', line 27

def watch(path = nil)
  path = File.expand_path(path || ".")
  compiler = Malvolio::Compiler.new(path, options[:no_warnings])
  html_files = Dir[File.join(path, "src", "**", "*.html")]
  css_files = Dir[File.join(path, "src", "**", "*.css")]
  sass_files = Dir[File.join(path, "src", "**", "*.scss")]
  files = html_files + css_files + sass_files
  puts "Now watching project for changes at #{path}"
  Filewatcher.new(files).watch do
    safely { compiler.run! }
  end
end