Class: Phlexite::Cli::Cli

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

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#buildObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/phlexite/cli/cli.rb', line 15

def build
  puts "\e[1m==> starting build\e[0m"
  file = options[:script] || "./build.rb"
  cmd = "#{RbConfig.ruby} #{file}"
  cmd = "bundle exec #{cmd}" if File.file? "Gemfile"

  system(cmd)

  puts "\e[1m==> build finished\e[0m"
end

#devObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/phlexite/cli/cli.rb', line 30

def dev
  build_dir = options[:build_dir] || "_build"

  build

  port = options[:port] || 3000
  puts "\e[1m=> Starting server on port #{port}\e[0m"
  Server.start port, build_dir

  puts "\e[1m=> Starting watcher (excluding #{build_dir} and gitignored files)\e[0m"
  Filewatcher
    .new("**/*.*", exclude:
      [File.join(build_dir, "**", "*.*")] +
      (File.read(".gitignore") || "").split("\n"))
    .watch do
      build
    end
end