Skip to content

Commit

Permalink
Added check for existing directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Apr 19, 2017
1 parent 98670d0 commit 686fd65
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions briefcase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import random
import re
import shutil
import sys
import uuid
from urllib.error import URLError
Expand Down Expand Up @@ -261,6 +262,24 @@ def post_run(self):
print("Installation complete.")

def run(self):
if os.path.exists(self.dir):
print()
if os.path.isdir(self.dir):
confirm = input("A directory named '%s' already exists. Would you like to replace it (y/N)? " % self.dir)
else:
confirm = input("A file named '%s' already exists. Would you like to delete it (y/N)? " % self.dir)

print()
if confirm in ['y', 'Y']:
print(" * Deleting existing content...")
if os.path.isdir(self.dir):
shutil.rmtree(self.dir)
else:
os.remove(self.dir)
else:
print("Briefcase deployment cancelled.")
return

self.generate_app_template()
self.install_app_requirements()
self.install_platform_requirements()
Expand Down

0 comments on commit 686fd65

Please sign in to comment.