Class: Bake::Command::Invoke

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/bake/command/invoke.rb

Instance Method Summary collapse

Instance Method Details

#bakefileObject



36
37
38
# File 'lib/bake/command/invoke.rb', line 36

def bakefile
	@parent.bakefile
end

#callObject



58
59
60
61
62
63
64
# File 'lib/bake/command/invoke.rb', line 58

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

#update_working_directoryObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bake/command/invoke.rb', line 40

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