Skip to content
Permalink
Browse files
handle bundle failures nicely
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 4, 2015
1 parent 9842055 commit 9ae58d0620a9cdef06e6dce7663f5f83d18e2117
Showing with 9 additions and 3 deletions.
  1. +9 −3 nikola/plugins/task/bundles.py
@@ -43,11 +43,12 @@ class BuildBundles(LateTask):
name = "create_bundles"

def set_site(self, site):
super(BuildBundles, self).set_site(site)
self.logger = utils.get_logger('bundles', site.loghandlers)
if webassets is None and self.site.config['USE_BUNDLES']:
utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
utils.LOGGER.warn('Setting USE_BUNDLES to False.')
self.logger.warn('Setting USE_BUNDLES to False.')
self.site.config['USE_BUNDLES'] = False
super(BuildBundles, self).set_site(site)

def gen_tasks(self):
"""Bundle assets using WebAssets."""
@@ -74,7 +75,12 @@ def build_bundle(output, inputs):
bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
env.register(output, bundle)
# This generates the file
env[output].urls()
try:
env[output].urls()
except Exception as e:
self.logger.error("Failed to build bundles.")
self.logger.exception(e)
self.logger.notice("Try running ``nikola clean`` and building again.")
else:
with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
pass # Create empty file

0 comments on commit 9ae58d0

Please sign in to comment.