-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto export user configuration on npm install
- Loading branch information
1 parent
08e8361
commit 272533f
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*/node_modules | ||
debomatic-webui/public/external_libs | ||
*/*/external_libs | ||
*/user.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/python | ||
|
||
# create a user.config.js file starting from lib/config.js | ||
|
||
import os | ||
|
||
base_path = os.environ['SCRIPTS_DIR'] | ||
|
||
global_config_file = os.path.join(base_path, '../lib/config.js') | ||
user_config_file = os.path.join(base_path, '../user.config.js') | ||
|
||
if os.path.isfile(user_config_file): | ||
print ("A config user file already exists. Skipping creation.") | ||
print user_config_file | ||
exit() | ||
|
||
export_header = """ | ||
/* | ||
* debomatic-webui user configuration | ||
*/ | ||
""" | ||
|
||
export_config = [] | ||
|
||
with open(global_config_file) as fd: | ||
start = False | ||
for line in fd: | ||
if line.find('#start config-auto-export') >= 0: | ||
start = True | ||
continue | ||
elif line.find('#end config-auto-export') >= 0: | ||
break | ||
if start: | ||
export_config.append(line) | ||
|
||
export_config.append('// DO NOT EDIT THIS LINE:\n') | ||
export_config.append('module.exports = config') | ||
|
||
print ("Creating user configuration ...") | ||
|
||
with open(user_config_file, 'w') as fd: | ||
fd.write(export_header) | ||
fd.write(''.join(export_config)) |