in setupbase.py [0:0]
def run(self):
if skip_npm:
log.info("Skipping npm-installation")
return
node_package = path or HERE
node_modules = pjoin(node_package, "node_modules")
is_yarn = os.path.exists(pjoin(node_package, "yarn.lock"))
npm_cmd = [npm] if isinstance(npm, str) else npm
if npm is None:
if is_yarn:
npm_cmd = ["yarn"]
else:
npm_cmd = ["npm"]
if not which(npm_cmd[0]):
log.error(
"`{0}` unavailable. If you're running this command "
"using sudo, make sure `{0}` is available to sudo".format(
npm_cmd[0]
)
)
return
if force or is_stale(node_modules, pjoin(node_package, "package.json")):
log.info(
"Installing build dependencies with npm. This may "
"take a while..."
)
run(npm_cmd + ["install"], cwd=node_package)
if build_dir and source_dir and not force:
should_build = is_stale(build_dir, source_dir)
else:
should_build = True
if should_build:
run(npm_cmd + ["run", build_cmd], cwd=node_package)