Module: Rain::CLI::Static

Extended by:
Static
Included in:
Static
Defined in:
lib/cli/static/static.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#build(application_path:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cli/static/static.rb', line 17

def build(application_path:)
   = LowLoad.dirload(File.expand_path('app', application_path))

  build_path = File.expand_path('build', application_path)
  FileUtils.rm_rf(build_path)
  FileUtils.mkdir_p(build_path)
  FileUtils.cp_r(File.expand_path('public', application_path), File.expand_path('public', build_path))

  request_paths(metadata:, application_path:).each do |result|
    path = File.expand_path(result.path, build_path)
    FileUtils.mkdir_p(path)
    File.write(File.expand_path('index.html', path), result.html)
  end
end