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
Core build Thor command.
Instance Attribute Details
#debugging ⇒ Object (readonly)
Returns the value of attribute debugging.
13 14 15 |
# File 'lib/middleman-core/cli/build.rb', line 13 def debugging @debugging end |
#had_errors ⇒ Object
Returns the value of attribute had_errors.
14 15 16 |
# File 'lib/middleman-core/cli/build.rb', line 14 def had_errors @had_errors end |
Class Method Details
.exit_on_failure? ⇒ Boolean
87 88 89 |
# File 'lib/middleman-core/cli/build.rb', line 87 def exit_on_failure? true end |
.shared_instance(verbose = false, instrument = false) ⇒ Middleman::Application
Middleman::Application singleton
94 95 96 97 98 99 |
# File 'lib/middleman-core/cli/build.rb', line 94 def shared_instance(verbose=false, instrument=false) @_shared_instance ||= ::Middleman::Application.server.inst do config[:environment] = :build ::Middleman::Logger.singleton(verbose ? 0 : 1, instrument) end end |
Instance Method Details
#build
This method returns an undefined value.
Core build Thor command
45 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 80 81 82 83 |
# File 'lib/middleman-core/cli/build.rb', line 45 def build unless ENV['MM_ROOT'] raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?' end require 'middleman-core' require 'middleman-core/logger' # 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 .key?('glob') opts[:clean] = ['clean'] self.class.shared_instance.run_hook :before_build, self action BuildAction.new(self, opts) self.class.shared_instance.run_hook :after_build, self if had_errors && !debugging msg = 'There were errors during this build' unless ['verbose'] msg << ', re-run with `middleman build --verbose` to see the full exception.' end shell.say msg, :red end exit(1) if had_errors end |