From f954415c95d76f2beb1bc3f4fbcf4c0a472be55f Mon Sep 17 00:00:00 2001 From: Jim Dalton Date: Mon, 11 Jan 2016 14:24:28 -0800 Subject: [PATCH] Add app method to detect mode --- middleman-core/lib/middleman-core/application.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 4efca949..88b6385a 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -327,18 +327,26 @@ module Middleman end end + # Whether we're in a specific mode + # @param [Symbol] key + # @return [Boolean] + Contract Symbol => Bool + def mode?(key) + config[:mode] == key + end + # Whether we're in server mode # @return [Boolean] If we're in dev mode Contract Bool def server? - config[:mode] == :server + mode?(:server) end # Whether we're in build mode # @return [Boolean] If we're in dev mode Contract Bool def build? - config[:mode] == :build + mode?(:build) end # Whether we're in a specific environment