Class: Middleman::Cli::Build
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Middleman::Cli::Build
- Includes:
- Thor::Actions
- Defined in:
- middleman-cli/lib/middleman-cli/build.rb
Overview
The CLI Build class
Instance Method Summary collapse
-
#build
Core build Thor command.
Instance Method Details
#build
This method returns an undefined value.
Core build Thor command
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'middleman-cli/lib/middleman-cli/build.rb', line 78 def build root = ENV['MM_ROOT'] || Dir.pwd raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?' unless File.exist?(File.join(root, 'config.rb')) require 'middleman-core' require 'middleman-core/logger' require 'middleman-core/builder' require 'fileutils' verbose = ['verbose'] ? 0 : 1 instrument = ['instrument'] builder = nil = ::Middleman::Logger.singleton(verbose, instrument) ::Middleman::Util.instrument 'builder.setup' do missing_and_changed = !['only_changed'] && ['missing_and_changed'] should_track_dependencies = ['only_changed'] || missing_and_changed || ['track_dependencies'] data_collection_depth = ['data_collection_depth'] @app = ::Middleman::Application.new do config[:mode] = :build config[:show_exceptions] = false config[:cli_options] = .each_with_object({}) do |(k, v), sum| sum[k] = v end config[:track_data_access] = should_track_dependencies config[:data_collection_depth] = data_collection_depth end builder = Middleman::Builder.new(@app, glob: ['glob'], dry_run: ['dry_run'], clean: ['clean'], parallel: ['parallel'], only_changed: ['only_changed'], missing_and_changed: missing_and_changed, track_dependencies: should_track_dependencies, visualize_graph: ['visualize_graph'], dependency_file: ['dependency_file']) builder.thor = self builder.on_build_event(&method(:on_event)) end ::Middleman::Util.instrument 'builder.run' do if builder.run! clean_directories! if ['clean'] puts 'Project built successfully.' else msg = 'There were errors during this build' msg = "#{msg}, re-run with `middleman build --verbose` to see the full exception." unless ['verbose'] shell.say msg, :red exit(1) end end end |