ask user before start destroying
This commit is contained in:
@@ -232,16 +232,18 @@ class Homesick < Thor
|
||||
def destroy(name)
|
||||
check_castle_existance name, "destroy"
|
||||
|
||||
inside castle_dir(name) do
|
||||
files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)}
|
||||
files.each do |path|
|
||||
if shell.yes?("This will destroy your castle irreversible! Are you sure?")
|
||||
inside castle_dir(name) do
|
||||
files = Pathname.glob('{.*,*}').reject{|a| [".",".."].include?(a.to_s)}
|
||||
files.each do |path|
|
||||
|
||||
inside home_dir do
|
||||
adjusted_path = (home_dir + path).basename
|
||||
rm adjusted_path
|
||||
inside home_dir do
|
||||
adjusted_path = (home_dir + path).basename
|
||||
rm adjusted_path
|
||||
end
|
||||
end
|
||||
rm_r castle_dir(name)
|
||||
end
|
||||
rm_rf repos_dir + name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -494,6 +494,7 @@ describe 'homesick' do
|
||||
|
||||
describe "destroy" do
|
||||
it "removes the symlink files" do
|
||||
expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y')
|
||||
given_castle("stronghold")
|
||||
some_rc_file = home.file '.some_rc_file'
|
||||
homesick.track(some_rc_file.to_s, "stronghold")
|
||||
@@ -503,6 +504,7 @@ describe 'homesick' do
|
||||
end
|
||||
|
||||
it "deletes the cloned repository" do
|
||||
expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y')
|
||||
castle = given_castle("stronghold")
|
||||
some_rc_file = home.file '.some_rc_file'
|
||||
homesick.track(some_rc_file.to_s, "stronghold")
|
||||
|
||||
Reference in New Issue
Block a user