Class: Middleman::Cli::Build
- Inherits:
-
Thor
- Object
- Thor
- Middleman::Cli::Build
- Includes:
- Thor::Actions
- Defined in:
- lib/middleman-core/cli/build.rb
Overview
The CLI Build class
Instance Attribute Summary collapse
-
#debugging ⇒ Object
readonly
Returns the value of attribute debugging.
-
#had_errors ⇒ Object
Returns the value of attribute had_errors.
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
-
.shared_instance(verbose = false, instrument = false) ⇒ Middleman::Application
Middleman::Application singleton.
Instance Method Summary collapse
-
#build ⇒ void
Core build Thor command.
Instance Attribute Details
#debugging ⇒ Object (readonly)
Returns the value of attribute debugging.
14 15 16 |
# File 'lib/middleman-core/cli/build.rb', line 14 def debugging @debugging end |
#had_errors ⇒ Object
Returns the value of attribute had_errors.
15 16 17 |
# File 'lib/middleman-core/cli/build.rb', line 15 def had_errors @had_errors end |
Class Method Details
.exit_on_failure? ⇒ Boolean
83 84 85 |
# File 'lib/middleman-core/cli/build.rb', line 83 def exit_on_failure? true end |
.shared_instance(verbose = false, instrument = false) ⇒ Middleman::Application
Middleman::Application singleton
90 91 92 93 94 95 |
# File 'lib/middleman-core/cli/build.rb', line 90 def shared_instance(verbose=false, instrument=false) @_shared_instance ||= ::Middleman::Application.server.inst do config[:environment] = :build logger(verbose ? 0 : 1, instrument) end end |
Instance Method Details
#build ⇒ void
This method returns an undefined value.
Core build Thor command
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/middleman-core/cli/build.rb', line 46 def build if !ENV["MM_ROOT"] raise Thor::Error, "Error: Could not find a Middleman project config, perhaps you are in the wrong folder?" end # Use Rack::Test for inspecting a running server for output require "rack" require "rack/test" require 'find' @debugging = Middleman::Cli::Base.respond_to?(:debugging) && Middleman::Cli::Base.debugging self.had_errors = false self.class.shared_instance(["verbose"], ["instrument"]) opts = {} opts[:glob] = ["glob"] if .has_key?("glob") opts[:clean] = ["clean"] action BuildAction.new(self, opts) self.class.shared_instance.run_hook :after_build, self if self.had_errors && !self.debugging msg = "There were errors during this build" unless ["verbose"] msg << ", re-run with `middleman build --verbose` to see the full exception." end self.shell.say msg, :red end exit(1) if self.had_errors end |