Skip to content

Commit

Permalink
Fix #137: Package.json overwritten if in default location
Browse files Browse the repository at this point in the history
  • Loading branch information
jyapayne committed May 14, 2016
1 parent f752484 commit 6ea4541
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def process_export_setting(self, ex_setting, output_dir,



def make_output_dirs(self):
def make_output_dirs(self, write_json=True):
output_dir = utils.path_join(self.output_dir(), self.project_name())
temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')

Expand All @@ -876,7 +876,9 @@ def make_output_dirs(self):
self.clean_dirs(temp_dir, output_dir)

self.copy_files_to_project_folder()
self.write_package_json()

if write_json:
self.write_package_json()

app_loc = self.get_app_nw_loc(temp_dir, output_dir)

Expand Down Expand Up @@ -1177,11 +1179,11 @@ def run_script(self, script):
self.progress_text = '\nThe script {} does not exist. Not running.'.format(script)


def export(self):
def export(self, write_json=True):
self.get_files_to_download()
res = self.try_to_download_files()
if res:
self.make_output_dirs()
self.make_output_dirs(write_json)
script = self.get_setting('custom_script').value
self.run_script(script)
self.progress_text = '\nDone!\n'
Expand Down Expand Up @@ -1452,12 +1454,23 @@ def my_excepthook(type_, value, tback):
if setting is not None:
setting.value = val

write_json = False

if args.load_json is True:
command_base.load_package_json()
elif args.load_json:
command_base.load_package_json(args.load_json)

command_base.export()
project_dir = command_base.project_dir()
json_path = os.path.abspath(os.path.expanduser(args.load_json))
left_over_path = json_path.replace(project_dir, '')

# Write package.json if it's not already in the root
# of the project
if left_over_path != 'package.json':
write_json = True

command_base.export(write_json)

if __name__ == '__main__':
main()

0 comments on commit 6ea4541

Please sign in to comment.