From 4e183df997323ac63d000f4b4b70371a3389cd59 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sat, 16 Jan 2016 12:31:09 -0800 Subject: [PATCH] Add npm start script --- package.json | 1 + script/start.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 script/start.py diff --git a/package.json b/package.json index 79f4cebc1101..69d5876ccc45 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "private": true, "scripts": { "preinstall": "node -e 'process.exit(0)'", + "start": "python ./script/start.py", "test": "python ./script/test.py" } } diff --git a/script/start.py b/script/start.py new file mode 100644 index 000000000000..76a079cb26ea --- /dev/null +++ b/script/start.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +import os +import subprocess +import sys + +from lib.util import atom_gyp + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + +PROJECT_NAME = atom_gyp()['project_name%'] +PRODUCT_NAME = atom_gyp()['product_name%'] + + +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())