Class: TRMNLP::Commands::Init
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from TRMNLP::Commands::Base
Instance Method Details
#call(name) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 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 |
# File 'lib/trmnlp/commands/init.rb', line 8 def call(name) destination_dir = Pathname.new(.dir).join(name) unless destination_dir.exist? output "Creating #{destination_dir}" destination_dir.mkpath end template_dir.glob('**/{*,.*}').each do |source_pathname| next if source_pathname.directory? next if .skip_liquid && source_pathname.extname == '.liquid' relative_pathname = source_pathname.relative_path_from(template_dir) destination_pathname = destination_dir.join(relative_pathname) destination_pathname.dirname.mkpath if destination_pathname.exist? answer = prompt("#{destination_pathname} already exists. Overwrite? (y/n): ").downcase if answer != 'y' output "Skipping #{destination_pathname}" next end end output "Creating #{destination_pathname}" FileUtils.cp(source_pathname, destination_pathname) end output <<~HEREDOC To start the local server: cd #{Pathname.new(destination_dir).relative_path_from(Dir.pwd)} trmnlp serve To publish the plugin: trmnlp login trmnlp push HEREDOC end |