MCPcopy Create free account
hub / github.com/ampproject/amphtml / GetNodeJsCmd

Function GetNodeJsCmd

validator/js/webui/build.py:31–43  ·  view source on GitHub ↗

Ensure Node.js is installed and return the proper command to run.

()

Source from the content-addressed store, hash-verified

29
30
31def GetNodeJsCmd():
32 """Ensure Node.js is installed and return the proper command to run."""
33 logging.info('entering ...')
34
35 for cmd in ['node', 'nodejs']:
36 try:
37 output = subprocess.check_output([cmd, '--eval', 'console.log("42")'])
38 if output.strip() == b'42':
39 logging.info('... done')
40 return cmd
41 except (subprocess.CalledProcessError, OSError):
42 continue
43 Die('Node.js not found. Try "apt-get install nodejs".')
44
45
46def CheckPrereqs():

Callers 1

MainFunction · 0.85

Calls 2

infoMethod · 0.80
DieFunction · 0.70

Tested by

no test coverage detected