Method: Frontman::CLI#init

Defined in:
lib/frontman/commands/init.rb

#init(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/frontman/commands/init.rb', line 11

def init(path)
  template = options[:template] || 'default'

  raise "Template #{template} does not exist!" unless template_exists?(template)

  target_dir = File.join(Dir.pwd, path == '.' ? '' : path)

  unless allowed_to_modify_dir?(target_dir)
    say 'Not bootstrapping new Frontman project'
    return
  end

  copy_template(template, target_dir)

  command = path == '.' ? '' : "cd #{path} && "
  command += 'bundle exec frontman serve'

  say "Your project is ready. Run `#{command}` and start developing!"
end