Sha256: 97dfeed7aacbbbf5b685a1b9cce42329d6b1320aa7e86adb66f6dc7aca623246
Contents?: true
Size: 1.86 KB
Versions: 10
Compression:
Stored size: 1.86 KB
Contents
# frozen_string_literal: true module Bridgetown module Commands class Apply < Thor::Group include Thor::Actions include Actions extend Summarizable Registrations.register do register(Apply, "apply", "apply", Apply.summary) end def self.banner "bridgetown apply PATH or URL" end summary "Applies an automation to the current site" def self.source_root Dir.pwd end def self.exit_on_failure? true end def apply_automation @source_paths = [Dir.pwd] if options[:apply] apply_after_new_command else apply_in_pwd end rescue SystemExit => e Bridgetown.logger.error "Problem occurred while running automation:" e.backtrace[0..3].each do |backtrace_line| Bridgetown.logger.info backtrace_line if backtrace_line.include?(":in `apply'") end raise e end protected def apply_after_new_command # Coming from the new command, so set up proper bundler env Bundler.with_clean_env do self.destination_root = New.created_site_dir inside(New.created_site_dir) do apply_from_url options[:apply] end end end def apply_in_pwd # Running standalone automation_command = args.empty? ? "bridgetown.automation.rb" : args[0] if args.empty? && !File.exist?("bridgetown.automation.rb") raise ArgumentError, "You must specify a path or a URL," \ " or add bridgetown.automation.rb to the" \ " current folder." end Bundler.with_clean_env do apply_from_url automation_command end rescue ArgumentError => e Bridgetown.logger.warn "Oops!", e.message end end end end
Version data entries
10 entries across 10 versions & 1 rubygems