MCPcopy
hub / github.com/ampproject/amphtml / EnsureNodeJsIsInstalled

Function EnsureNodeJsIsInstalled

validator/build.py:26–39  ·  view source on GitHub ↗

Ensure Node.js is installed and that 'node' is the command to run.

()

Source from the content-addressed store, hash-verified

24
25
26def EnsureNodeJsIsInstalled():
27 """Ensure Node.js is installed and that 'node' is the command to run."""
28 logging.info('entering ...')
29
30 try:
31 output = subprocess.check_output(['node', '--eval', 'console.log("42")'])
32 if b'42' == output.strip():
33 return
34 except (subprocess.CalledProcessError, OSError):
35 pass
36 Die('Node.js not found. Try "apt-get install nodejs" or follow the install'
37 'instructions at'
38 'https://github.com/ampproject/amphtml/blob/main/validator/README.md#installation'
39 )
40
41
42def CheckPrereqs():

Callers 1

MainFunction · 0.85

Calls 2

infoMethod · 0.80
DieFunction · 0.70

Tested by

no test coverage detected