2 from subprocess import call
3 from optparse import make_option
5 from django.core.management.base import BaseCommand, CommandError
6 from django.core.management import call_command
9 class Command(BaseCommand):
11 option_list = BaseCommand.option_list + (
12 make_option('--node-bin-path',
17 help='Path to node binary'),
18 make_option('--npm-bin',
23 help='Path to npm binary'),
26 def handle(self, **options):
27 wiki_base_dir = os.path.join(os.getcwd(), 'apps', 'wiki', 'static', 'wiki')
28 rng_base_dir = os.path.join(wiki_base_dir, 'editor')
29 build_dir = os.path.join(wiki_base_dir, 'build')
31 self.stdout.write('Installing editor dependencies')
33 call([options['npm_bin'], 'install'], cwd = rng_base_dir)
35 raise CommandError('Something went wrong, propably npm binary not found. Tried: %s' % options['npm_bin'])
37 self.stdout.write('Building editor')
38 if options['node_bin_path']:
39 # grunt needs npm binary to be foundable in PATH
40 os.environ['PATH'] = '%s:%s' % (options['node_bin_path'], os.environ['PATH'])
41 call(['./node_modules/.bin/grunt', 'build', '--output-dir=%s' % build_dir], cwd = rng_base_dir)
43 call_command('collectstatic', interactive = False, ignore_patterns = ['editor'])