Sha256: c4f3df9b5750ecdf42064cc9ec1279eb673c81a3da02af3dedbe6141525b3ce1

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'fileutils'

# Class for forger compile command
class Forger::Script
  class Compile < Forger::Base
    include Forger::Template

    # used in upload
    def compile_scripts
      clean
      compile_folder("scripts")
    end

    # use in compile cli command
    def compile_all
      clean
      compile_folder("scripts")
      layout_path = context.layout_path(@options[:layout])
      compile_folder("user-data", layout_path)
    end

    def compile_folder(folder, layout_path=false)
      puts "Compiling app/#{folder} to tmp/app/#{folder}.".color(:green)
      Dir.glob("#{Forger.root}/app/#{folder}/**/*").each do |path|
        next if File.directory?(path)
        next if path.include?("layouts")

        result = RenderMePretty.result(path, layout: layout_path, context: context)
        tmp_path = path.sub(%r{.*/app/}, "#{BUILD_ROOT}/app/")
        puts "  #{tmp_path}" if @options[:verbose]
        FileUtils.mkdir_p(File.dirname(tmp_path))
        IO.write(tmp_path, result)
      end
    end

    def clean
      FileUtils.rm_rf("#{BUILD_ROOT}/app")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
forger-3.0.2 lib/forger/script/compile.rb
forger-3.0.1 lib/forger/script/compile.rb
forger-3.0.0 lib/forger/script/compile.rb
forger-2.0.5 lib/forger/script/compile.rb