@@ -456,26 +456,30 @@ def process_webexe_settings(self, dic, global_json):
456456 if setting .value is not None :
457457 dic ['webexe_settings' ][setting_name ] = setting .value
458458
459+ def generate_web2exe_json (self , global_json = False ):
460+ """Generates web2exe's settings json"""
461+ self .logger .info ('Generating web2exe json file...' )
459462
460- def generate_json (self , global_json = False ):
461- """Generates the json config files for the exported app"""
462- self .logger .info ('Generating package.json...' )
463+ web2exe_dic = {'webexe_settings' : {}}
463464
464- dic = { 'webexe_settings' : {}}
465+ self . process_webexe_settings ( web2exe_dic , global_json )
465466
466- if not global_json :
467- dic .update ({'webkit' : {}, 'window' : {}})
468- dic .update (self .original_packagejson )
467+ return json .dumps (web2exe_dic , indent = 4 , sort_keys = True )
468+
469+ def generate_project_json (self ):
470+ """Generates the json config files for the exported app"""
471+ self .logger .info ('Generating package.json...' )
469472
470- self .process_app_settings (dic )
471- self .process_window_settings (dic )
472- self .process_webkit_settings (dic )
473+ dic = {}
473474
474- self .process_webexe_settings (dic , global_json )
475+ dic .update ({'webkit' : {}, 'window' : {}})
476+ dic .update (self .original_packagejson )
475477
476- s = json .dumps (dic , indent = 4 , sort_keys = True )
478+ self .process_app_settings (dic )
479+ self .process_window_settings (dic )
480+ self .process_webkit_settings (dic )
477481
478- return s
482+ return json . dumps ( dic , indent = 4 , sort_keys = True )
479483
480484 @property
481485 def extract_error (self ):
@@ -636,18 +640,23 @@ def replace_icon_in_exe(self, exe_path):
636640 def write_package_json (self ):
637641 """Collects filled options and writes corresponding json files"""
638642 json_file = utils .path_join (self .project_dir (), 'package.json' )
643+ w2e_json_file = utils .path_join (self .project_dir (),
644+ config .WEB2EXE_JSON_FILE )
639645
640646 global_json = utils .get_data_file_path (config .GLOBAL_JSON_FILE )
641647
642648 # Write package json
643649 if self .output_package_json :
644650 with codecs .open (json_file , 'w+' , encoding = 'utf-8' ) as f :
645- f .write (self .generate_json ())
651+ f .write (self .generate_project_json ())
652+ with codecs .open (w2e_json_file ,
653+ 'w+' , encoding = 'utf-8' ) as f :
654+ f .write (self .generate_web2exe_json ())
646655
647656 # Write global settings that are kept when installing new
648657 # versions
649658 with codecs .open (global_json , 'w+' , encoding = 'utf-8' ) as f :
650- f .write (self .generate_json (global_json = True ))
659+ f .write (self .generate_web2exe_json (global_json = True ))
651660
652661 def clean_dirs (self , * dirs ):
653662 """
@@ -1603,25 +1612,6 @@ def read_package_json_file(args, command_base):
16031612 # Load json is a path, so load JSON from the specified file
16041613 command_base .load_package_json (args .load_json )
16051614
1606- def write_package_json_file (args , command_base ):
1607- """Determine whether or not to write the package json file."""
1608- write_json = False
1609-
1610- if args .load_json is not True and args .load_json :
1611- # Load json is a path, so check if the default package json
1612- # exists before writing it. If it exists, don't overwrite it
1613- # so that people's changes to the file are preserved
1614- project_dir = command_base .project_dir ()
1615- json_path = os .path .abspath (os .path .expanduser (args .load_json ))
1616- left_over_path = json_path .replace (project_dir , '' )
1617-
1618- # Write package.json if it's not already in the root
1619- # of the project
1620- if left_over_path != 'package.json' :
1621- write_json = True
1622-
1623- command_base .export (write_json )
1624-
16251615def initialize_setting_values (args , command_base ):
16261616 for name , val in args ._get_kwargs ():
16271617 if callable (val ):
@@ -1650,7 +1640,9 @@ def main():
16501640 initialize_setting_values (args , command_base )
16511641
16521642 read_package_json_file (args , command_base )
1653- write_package_json_file (args , command_base )
1643+
1644+ # Never write package.json on command line. Only load it.
1645+ command_base .export (write_json = False )
16541646
16551647if __name__ == '__main__' :
16561648 main ()
0 commit comments