Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Commit

Permalink
Pass config and flags through to our command
Browse files Browse the repository at this point in the history
  • Loading branch information
wfarr committed Nov 26, 2013
1 parent d675682 commit 7247c4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/boxen/commands/command.rb
@@ -1,4 +1,6 @@
require "boxen/commands"
require "boxen/config"
require "boxen/flags"

module Boxen
module Commands
Expand All @@ -23,13 +25,15 @@ def postflight(*klasses)
end

def initialize(*args)
@args = args
@config = Boxen::Config.load
@flags = Boxen::Flags.new(args).apply(@config)
@args = args
end

def invoke
if self.class.preflight.all? { |p| p = p.new; p.run unless p.ok? }
if self.class.preflight.all? { |p| p = p.new(@config); p.run unless p.ok? }
self.run
self.class.postflight.each { |p| p = p.new; p.run unless p.ok? }
self.class.postflight.each { |p| p = p.new(@config); p.run unless p.ok? }
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/commands_test.rb
@@ -1,7 +1,7 @@
require "boxen/commands"

class Failing < Boxen::Check
def initialize; end
def initialize(*args); end
def ok?; false; end
def run; warn "lol this fails in ur face"; end
end
Expand Down

0 comments on commit 7247c4b

Please sign in to comment.