lib/aws_ec2/script/compile.rb in aws-ec2-0.9.0 vs lib/aws_ec2/script/compile.rb in aws-ec2-1.0.0

- old
+ new

@@ -1,23 +1,32 @@ require 'fileutils' # Class for aws-ec2 compile command class AwsEc2::Script class Compile < AwsEc2::Base - include AwsEc2::TemplateHelper - BUILD_ROOT = "tmp" + include AwsEc2::Template - def compile + # used in upload + def compile_scripts clean compile_folder("scripts") - compile_folder("user-data") end - def compile_folder(folder) + # 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}:".colorize(:green) Dir.glob("#{AwsEc2.root}/app/#{folder}/**/*").each do |path| next if File.directory?(path) - result = erb_result(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}" FileUtils.mkdir_p(File.dirname(tmp_path)) IO.write(tmp_path, result) end