parameters: (node_check, cwd)
docstring: Check node version and install npm packages.
docstring_summary: Check node version and install npm packages.
docstring_tokens: Check node version and install npm packages .
function: def check_node(node_check, cwd):
      """Check node version and install npm packages."""
  
      status, output = subprocess.getstatusoutput(node_check)
      if status != 0 or not output.split('\n')[-1].startswith('v12'):
          print(
              textwrap.dedent(f"""\
              Failed to get node version 12 from 'node -v':
              output: '{output}'
              Perhaps run 'source {cwd}/setup_node_env.sh install'"""))
          exit(1)
  
      node_modules = cwd / 'node_modules'
  
      if not node_modules.exists():
          print(
              textwrap.dedent(f"""\
              {node_modules} not found, you need to run 'npm install' in {cwd}
              Perhaps run 'source {cwd}/setup_node_env.sh install'"""))
          exit(1)
function_tokens: def check_node ( node_check , cwd ) : status , output = subprocess . getstatusoutput ( node_check ) if status != 0 or not output . split ( '\n' ) [ - 1 ] . startswith ( 'v12' ) : print ( textwrap . dedent ( f"""\
              Failed to get node version 12 from 'node -v':
              output: '{output}'
              Perhaps run 'source {cwd}/setup_node_env.sh install'""" ) ) exit ( 1 ) node_modules = cwd / 'node_modules' if not node_modules . exists ( ) : print ( textwrap . dedent ( f"""\
              {node_modules} not found, you need to run 'npm install' in {cwd}
              Perhaps run 'source {cwd}/setup_node_env.sh install'""" ) ) exit ( 1 )