inside (dir = "", config = {}, &block)
public
Do something in the root or on a provided subfolder. If a relative path is
given it’s referenced from the current root. The full path is yielded to
the block you provide. The path is set back to the previous path when the
method exits.
Parameters
Show source # File lib/bundler/vendor/thor/lib/thor/actions.rb, line 167
def inside(dir = "", config = {}, &block)
verbose = config.fetch(:verbose, false)
pretend = options[:pretend]
say_status :inside, dir, verbose
shell.padding += 1 if verbose
@destination_stack.push File.expand_path(dir, destination_root)
# If the directory doesnt exist and we're not pretending
if !File.exist?(destination_root) && !pretend
require "fileutils"
FileUtils.mkdir_p(destination_root)
end
if pretend
# In pretend mode, just yield down to the block
block.arity == 1 ? yield(destination_root) : yield
else
require "fileutils"
FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
end
@destination_stack.pop
shell.padding -= 1 if verbose
end