electron/script/start.py

41 lines
956 B
Python
Raw Normal View History

2016-01-16 20:31:09 +00:00
#!/usr/bin/env python
import os
import subprocess
import sys
2016-05-25 16:10:46 +00:00
from lib.util import electron_gyp
2016-01-16 20:31:09 +00:00
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
2016-05-25 16:10:46 +00:00
PROJECT_NAME = electron_gyp()['project_name%']
PRODUCT_NAME = electron_gyp()['product_name%']
2016-01-16 20:31:09 +00:00
def main():
os.chdir(SOURCE_ROOT)
config = 'D'
if '-R' in sys.argv:
config = 'R'
if sys.platform == 'darwin':
electron = os.path.join(SOURCE_ROOT, 'out', config,
'{0}.app'.format(PRODUCT_NAME), 'Contents',
'MacOS', PRODUCT_NAME)
elif sys.platform == 'win32':
electron = os.path.join(SOURCE_ROOT, 'out', config,
'{0}.exe'.format(PROJECT_NAME))
else:
electron = os.path.join(SOURCE_ROOT, 'out', config, PROJECT_NAME)
try:
subprocess.check_call([electron] + sys.argv[1:])
except KeyboardInterrupt:
return -1
if __name__ == '__main__':
sys.exit(main())