-
Notifications
You must be signed in to change notification settings - Fork 2k
/
asset.py
46 lines (32 loc) · 1.28 KB
/
asset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# encoding: utf-8
import logging
import click
from webassets import script
from webassets.exceptions import BundleError
from ckan.lib import webassets_tools
from ckan.cli import error_shout
log = logging.getLogger(__name__)
@click.group(name=u'asset', short_help=u'WebAssets commands')
def asset():
pass
@asset.command(u'build', short_help=u'Builds all bundles.')
def build():
u'''Builds bundles, regardless of whether they are changed or not.'''
script.main(['build'], webassets_tools.env)
click.secho(u'Compile assets: SUCCESS', fg=u'green', bold=True)
@asset.command(u'watch', short_help=u'Watch changes in source files.')
def watch():
u'''Start a daemon which monitors source files, and rebuilds bundles.
This can be useful during development, if building is not
instantaneous, and you are losing valuable time waiting for the
build to finish while trying to access your site.
'''
script.main(['watch'], webassets_tools.env)
@asset.command(u'clean', short_help=u'Clear cache.')
def clean():
u'''Will clear out the cache, which after a while can grow quite large.'''
try:
script.main(['clean'], webassets_tools.env)
except BundleError as e:
return error_shout(e)
click.secho(u'Clear cache: SUCCESS', fg=u'green', bold=True)