Added simple implementation to check if git is installed before
executing commands.
This commit is contained in:
@@ -19,8 +19,13 @@ module Homesick
|
|||||||
|
|
||||||
def initialize(args = [], options = {}, config = {})
|
def initialize(args = [], options = {}, config = {})
|
||||||
super
|
super
|
||||||
self.shell = Thor::Shell::Color.new
|
# Check if git is installed
|
||||||
|
unless `git --version`.size > 0
|
||||||
|
say_status :error, 'Git must be installed to use Homesick', :red
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
# Hack in support for diffing symlinks
|
# Hack in support for diffing symlinks
|
||||||
|
self.shell = Thor::Shell::Color.new
|
||||||
class << shell
|
class << shell
|
||||||
def show_diff(destination, content)
|
def show_diff(destination, content)
|
||||||
destination = Pathname.new(destination)
|
destination = Pathname.new(destination)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ describe Homesick::CLI do
|
|||||||
|
|
||||||
before { allow(homesick).to receive(:repos_dir).and_return(castles) }
|
before { allow(homesick).to receive(:repos_dir).and_return(castles) }
|
||||||
|
|
||||||
describe 'smoke test' do
|
describe 'smoke tests' do
|
||||||
context 'when running bin/homesick' do
|
context 'when running bin/homesick' do
|
||||||
before do
|
before do
|
||||||
bin_path = Pathname.new(__FILE__).parent.parent
|
bin_path = Pathname.new(__FILE__).parent.parent
|
||||||
@@ -23,6 +23,17 @@ describe Homesick::CLI do
|
|||||||
expect(@output.length).to be > 0
|
expect(@output.length).to be > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when git is not installed' do
|
||||||
|
before do
|
||||||
|
# The following line suppresses Thor warnings about overriding methods.
|
||||||
|
allow($stdout).to receive(:write).at_least(:once)
|
||||||
|
expect_any_instance_of(Homesick::CLI).to receive(:`).and_return('')
|
||||||
|
end
|
||||||
|
it 'should raise an exception when Git is not installed' do
|
||||||
|
Capture.stdout{ expect{Homesick::CLI.new}.to raise_error SystemExit }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'clone' do
|
describe 'clone' do
|
||||||
|
|||||||
Reference in New Issue
Block a user