Merge pull request #48 from trobrock/fix-homesickrc
Fix #19 homesickrc pathname needs a to_s to eval
This commit is contained in:
@@ -52,13 +52,21 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rc(destination)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc 'rc CASTLE', 'Run the .homesickrc for the specified castle'
|
||||||
|
def rc(name = DEFAULT_CASTLE_NAME)
|
||||||
|
inside repos_dir do
|
||||||
|
destination = Pathname.new(name)
|
||||||
homesickrc = destination.join('.homesickrc').expand_path
|
homesickrc = destination.join('.homesickrc').expand_path
|
||||||
if homesickrc.exist?
|
if homesickrc.exist?
|
||||||
proceed = shell.yes?("#{uri} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
|
proceed = shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
|
||||||
if proceed
|
if proceed
|
||||||
shell.say_status 'eval', homesickrc
|
shell.say_status 'eval', homesickrc
|
||||||
inside destination do
|
inside destination do
|
||||||
eval homesickrc.read, binding, homesickrc.expand_path
|
eval homesickrc.read, binding, homesickrc.expand_path.to_s
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue
|
shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ describe 'homesick' do
|
|||||||
before { homesick.stub!(:repos_dir).and_return(castles) }
|
before { homesick.stub!(:repos_dir).and_return(castles) }
|
||||||
|
|
||||||
describe 'clone' do
|
describe 'clone' do
|
||||||
|
context 'has a .homesickrc' do
|
||||||
|
it 'should run the .homesickrc' do
|
||||||
|
somewhere = create_construct
|
||||||
|
local_repo = somewhere.directory('some_repo')
|
||||||
|
local_repo.file('.homesickrc') do |file|
|
||||||
|
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect($stdout).to receive(:print)
|
||||||
|
expect($stdin).to receive(:gets).and_return('y')
|
||||||
|
homesick.clone local_repo
|
||||||
|
|
||||||
|
castles.join('some_repo').join('testing').should exist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'of a file' do
|
context 'of a file' do
|
||||||
it 'should symlink existing directories' do
|
it 'should symlink existing directories' do
|
||||||
somewhere = create_construct
|
somewhere = create_construct
|
||||||
@@ -84,6 +100,44 @@ describe 'homesick' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'rc' do
|
||||||
|
let(:castle) { given_castle('glencairn') }
|
||||||
|
|
||||||
|
context 'when told to do so' do
|
||||||
|
before do
|
||||||
|
expect($stdout).to receive(:print)
|
||||||
|
expect($stdin).to receive(:gets).and_return('y')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'executes the .homesickrc' do
|
||||||
|
castle.file('.homesickrc') do |file|
|
||||||
|
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
||||||
|
end
|
||||||
|
|
||||||
|
homesick.rc castle
|
||||||
|
|
||||||
|
castle.join('testing').should exist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when told not to do so' do
|
||||||
|
before do
|
||||||
|
expect($stdout).to receive(:print)
|
||||||
|
expect($stdin).to receive(:gets).and_return('n')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not execute the .homesickrc' do
|
||||||
|
castle.file('.homesickrc') do |file|
|
||||||
|
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
||||||
|
end
|
||||||
|
|
||||||
|
homesick.rc castle
|
||||||
|
|
||||||
|
castle.join('testing').should_not exist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'symlink' do
|
describe 'symlink' do
|
||||||
let(:castle) { given_castle('glencairn') }
|
let(:castle) { given_castle('glencairn') }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user