mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 17:27:22 +08:00
- Comparison with 0 should use != and not `is not` - stderr and stdout can be None, meaning they can't be concatenated Change-Id: Ib84b969b1f7fec2c03a0aea095521f8c7ab3674e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2485073 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Philip Pfaffe <pfaffe@chromium.org>
47 lines
1.3 KiB
Python
Executable File
47 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright 2017 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
from os import path as os_path
|
|
import platform
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
|
|
def GetBinaryPath():
|
|
return os_path.join(
|
|
os_path.dirname(__file__), *{
|
|
'Darwin': ('mac', 'node-darwin-x64', 'bin', 'node'),
|
|
'Linux': ('linux', 'node-linux-x64', 'bin', 'node'),
|
|
'Windows': ('win', 'node.exe'),
|
|
}[platform.system()])
|
|
|
|
|
|
def RunNode(cmd_parts, output=subprocess.PIPE):
|
|
cmd = [GetBinaryPath()] + cmd_parts
|
|
process = subprocess.Popen(cmd,
|
|
cwd=os.getcwd(),
|
|
stdout=output,
|
|
stderr=output)
|
|
stdout, stderr = process.communicate()
|
|
|
|
if process.returncode != 0:
|
|
print('%s failed:\n%s\n%s' % (cmd, stdout, stderr))
|
|
exit(process.returncode)
|
|
|
|
return stdout
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = sys.argv[1:]
|
|
# Accept --output as the first argument, and then remove
|
|
# it from the args entirely if present.
|
|
if len(args) > 0 and args[0] == '--output':
|
|
output = None
|
|
args = sys.argv[2:]
|
|
else:
|
|
output = subprocess.PIPE
|
|
RunNode(args, output)
|