class Bake::Command::Call

def bakefile

def bakefile
	@parent.bakefile
end

def call

def call
	context = @parent.context
	
	self.update_working_directory
	
	context.call(*@commands)
end

def update_working_directory

def update_working_directory
	if bakefile = self.bakefile
		current_directory = Dir.pwd
		working_directory = File.dirname(bakefile)
		
		if working_directory != current_directory
			Console.logger.debug(self) {"Changing working directory to #{working_directory.inspect}."}
			Dir.chdir(working_directory)
			
			return current_directory
		end
	end
	
	return nil
end