def run(self):
has_npm = self.has_npm()
if not has_npm:
log.error(
"`npm` unavailable. If you're running this command using "
"sudo, make sure `npm` is available to sudo"
)
env = os.environ.copy()
env['PATH'] = npm_path
if self.should_run_npm_install():
log.info(
"Installing build dependencies with npm. "
"This may take a while..."
)
check_call(
['npm', 'install'],
cwd=node_root, stdout=sys.stdout, stderr=sys.stderr
)
log.info(
"Building static assets. "
)
check_call(
['npm', 'run', 'build'],
cwd=node_root, stdout=sys.stdout, stderr=sys.stderr
)
os.utime(self.node_modules, None)
for t in self.targets:
if not os.path.exists(t):
msg = 'Missing file: %s' % t
if not has_npm:
msg += '\nnpm is required to build a development version'
raise ValueError(msg)
# update package data in case this created new files
update_package_data(self.distribution)
评论列表
文章目录