mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: revise install.py for minor improvements
* Use an with block for reading the config file. Refs: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files * Use explicit blank return to make it clear that the return value is not actually used and that it is being used for flow control only.. PR-URL: https://github.com/nodejs/node/pull/36626 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Christian Clauss <cclauss@me.com>
This commit is contained in:
@@ -19,8 +19,8 @@ def abspath(*args):
|
||||
return os.path.abspath(path)
|
||||
|
||||
def load_config():
|
||||
s = open('config.gypi').read()
|
||||
return ast.literal_eval(s)
|
||||
with open('config.gypi') as f:
|
||||
return ast.literal_eval(f.read())
|
||||
|
||||
def try_unlink(path):
|
||||
try:
|
||||
@@ -223,11 +223,19 @@ def run(args):
|
||||
cmd = args[1] if len(args) > 1 else 'install'
|
||||
|
||||
if os.environ.get('HEADERS_ONLY'):
|
||||
if cmd == 'install': return headers(install)
|
||||
if cmd == 'uninstall': return headers(uninstall)
|
||||
if cmd == 'install':
|
||||
headers(install)
|
||||
return
|
||||
if cmd == 'uninstall':
|
||||
headers(uninstall)
|
||||
return
|
||||
else:
|
||||
if cmd == 'install': return files(install)
|
||||
if cmd == 'uninstall': return files(uninstall)
|
||||
if cmd == 'install':
|
||||
files(install)
|
||||
return
|
||||
if cmd == 'uninstall':
|
||||
files(uninstall)
|
||||
return
|
||||
|
||||
raise RuntimeError('Bad command: %s\n' % cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user