Ensure Node.js is installed and return the proper command to run.
()
| 29 | |
| 30 | |
| 31 | def 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 | |
| 46 | def CheckPrereqs(): |