lib/kapost/bootstrapper.rb in kapost-bootstrapper-0.2.0 vs lib/kapost/bootstrapper.rb in kapost-bootstrapper-0.3.0

- old
+ new

@@ -10,18 +10,10 @@ @shell = shell run(&block) if block_given? end - def osx(&block) - instance_eval(&block) if os == :macosx - end - - def debian(&block) - instance_eval(&block) if os == :debian - end - def check(command, help = nil, version: nil, &block) success = say(label(command, version)) do if block_given? yield else @@ -78,10 +70,22 @@ status = $? fail "Command `#{cmd.join(' ')}` failed with status #{status.exitstatus}" unless result result end + def osx(&block) + run(&block) if os == :macosx + end + + def docker(&block) + run(&block) if os == :docker + end + + def ubuntu(&block) + run(&block) if os == :ubuntu + end + def run(&code) instance_eval(&code) end private @@ -97,10 +101,16 @@ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :macosx when /linux/ - installed?("apt-get") ? :debian : :linux + if File.exist?("/.dockerenv") + :docker + elsif installed?("apt-get") + :ubuntu + else + :linux + end else fail "unknown os: #{RUBY_PLATFORM.inspect}" end end end