MCPcopy Index your code
hub / github.com/emscripten-core/emsdk / emscripten_npm_install

Function emscripten_npm_install

emsdk.py:1441–1479  ·  view source on GitHub ↗
(tool, directory)

Source from the content-addressed store, hash-verified

1439
1440# npm install in Emscripten root directory
1441def emscripten_npm_install(tool, directory):
1442 node_tool = find_latest_installed_tool('node')
1443 if not node_tool:
1444 npm_fallback = shutil.which('npm')
1445 if not npm_fallback:
1446 errlog('Failed to find npm command')
1447 errlog(f'Running "npm ci" in installed Emscripten root directory {tool.installation_path()} is required')
1448 errlog('Please install node.js first')
1449 return False
1450 node_path = os.path.dirname(npm_fallback)
1451 else:
1452 node_path = os.path.join(node_tool.installation_path(), 'bin')
1453
1454 npm = os.path.join(node_path, 'npm' + ('.cmd' if WINDOWS else ''))
1455 env = os.environ.copy()
1456 env["PATH"] = node_path + os.pathsep + env["PATH"]
1457 print('Running post-install step: npm ci ...')
1458 try:
1459 subprocess.check_output(
1460 [npm, 'ci', '--production'],
1461 cwd=directory, stderr=subprocess.STDOUT, env=env,
1462 universal_newlines=True)
1463 except subprocess.CalledProcessError as e:
1464 errlog('Error running %s:\n%s' % (e.cmd, e.output))
1465 return False
1466
1467 print('Done running: npm ci')
1468
1469 if os.path.isfile(os.path.join(directory, 'bootstrap.py')):
1470 try:
1471 subprocess.check_output([sys.executable, os.path.join(directory, 'bootstrap.py')],
1472 cwd=directory, stderr=subprocess.STDOUT, env=env,
1473 universal_newlines=True)
1474 except subprocess.CalledProcessError as e:
1475 errlog('Error running %s:\n%s' % (e.cmd, e.output))
1476 return False
1477
1478 print('Done running: Emscripten bootstrap')
1479 return True
1480
1481
1482# Binaryen build scripts:

Callers 2

install_sdkMethod · 0.85
install_toolMethod · 0.85

Calls 3

errlogFunction · 0.85
installation_pathMethod · 0.80

Tested by

no test coverage detected