19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rdm/cli/compile_package.rb', line 19
def compile
Rdm::SourceParser.read_and_init_source(Rdm::SourceLocator.locate(@project_path))
@overwrite_directory ||= ->() { STDIN.gets.chomp.downcase == YES }
@compile_path ||= Rdm.settings.compile_path
if @package_name.blank?
puts 'Package name was not specified. Ex: rdm compile.package PACKAGE_NAME'
return
end
if @compile_path.blank?
puts 'Destination path was not specified. Ex: rdm compile.package package_name --path FOLDER_PATH'
return
end
if Dir.exist?(@compile_path)
puts "Destination directory exists. Overwrite it? (y/n)"
return unless @overwrite_directory.call
end
compiled_packages = Rdm::Packages::CompilerService.compile(
package_name: @package_name,
project_path: @project_path,
compile_path: @compile_path
)
formatted_packages = compiled_packages.sort.map {|pkg| " - #{pkg}"}
puts "\n Compilation for package '\#{@package_name}' started.\n The following packages were copied:\n \#{formatted_packages.join(\"\\n\")}\n EOF\n\nrescue Rdm::Errors::SourceFileDoesNotExist => e\n puts \"Rdm.packages was not found. Run 'rdm init' to create it\"\nend\n"
|