Skip to content

Commit 6ea4541

Browse files
committed
Fix #137: Package.json overwritten if in default location
1 parent f752484 commit 6ea4541

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

command_line.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def process_export_setting(self, ex_setting, output_dir,
867867

868868

869869

870-
def make_output_dirs(self):
870+
def make_output_dirs(self, write_json=True):
871871
output_dir = utils.path_join(self.output_dir(), self.project_name())
872872
temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')
873873

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

878878
self.copy_files_to_project_folder()
879-
self.write_package_json()
879+
880+
if write_json:
881+
self.write_package_json()
880882

881883
app_loc = self.get_app_nw_loc(temp_dir, output_dir)
882884

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

11791181

1180-
def export(self):
1182+
def export(self, write_json=True):
11811183
self.get_files_to_download()
11821184
res = self.try_to_download_files()
11831185
if res:
1184-
self.make_output_dirs()
1186+
self.make_output_dirs(write_json)
11851187
script = self.get_setting('custom_script').value
11861188
self.run_script(script)
11871189
self.progress_text = '\nDone!\n'
@@ -1452,12 +1454,23 @@ def my_excepthook(type_, value, tback):
14521454
if setting is not None:
14531455
setting.value = val
14541456

1457+
write_json = False
1458+
14551459
if args.load_json is True:
14561460
command_base.load_package_json()
14571461
elif args.load_json:
14581462
command_base.load_package_json(args.load_json)
14591463

1460-
command_base.export()
1464+
project_dir = command_base.project_dir()
1465+
json_path = os.path.abspath(os.path.expanduser(args.load_json))
1466+
left_over_path = json_path.replace(project_dir, '')
1467+
1468+
# Write package.json if it's not already in the root
1469+
# of the project
1470+
if left_over_path != 'package.json':
1471+
write_json = True
1472+
1473+
command_base.export(write_json)
14611474

14621475
if __name__ == '__main__':
14631476
main()

0 commit comments

Comments
 (0)