mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-16 03:05:32 +01:00
...
This commit is contained in:
parent
0312261cc5
commit
446eb08a55
1 changed files with 15 additions and 9 deletions
|
|
@ -6,7 +6,7 @@
|
|||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, cPickle, re, shutil, marshal, zipfile, glob, subprocess, time
|
||||
import os, cPickle, re, shutil, marshal, zipfile, glob, time
|
||||
from zlib import compress
|
||||
|
||||
from setup import Command, basenames, __appname__
|
||||
|
|
@ -35,6 +35,8 @@ def add_options(self, parser):
|
|||
help='Display the generated javascript')
|
||||
|
||||
def run(self, opts):
|
||||
from calibre.utils.coffeescript import compile_coffeescript
|
||||
self.compiler = compile_coffeescript
|
||||
self.do_coffee_compile(opts)
|
||||
if opts.watch:
|
||||
try:
|
||||
|
|
@ -61,20 +63,24 @@ def do_coffee_compile(self, opts, timestamp=False, ignore_errors=False):
|
|||
if self.newer(js, x):
|
||||
print ('\t%sCompiling %s'%(time.strftime('[%H:%M:%S] ') if
|
||||
timestamp else '', os.path.basename(x)))
|
||||
try:
|
||||
subprocess.check_call(['coffee', '-c', '-o', dest, x])
|
||||
except:
|
||||
with open(x, 'rb') as f:
|
||||
cs, errs = self.compiler(f.read())
|
||||
for line in errs:
|
||||
print (line)
|
||||
if cs and not errs:
|
||||
with open(js, 'wb') as f:
|
||||
f.write(cs.encode('utf-8'))
|
||||
if opts.show_js:
|
||||
self.show_js(js)
|
||||
print ('#'*80)
|
||||
print ('#'*80)
|
||||
else:
|
||||
print ('\n\tCompilation of %s failed'%os.path.basename(x))
|
||||
if ignore_errors:
|
||||
with open(js, 'wb') as f:
|
||||
f.write('# Compilation from coffeescript failed')
|
||||
else:
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
if opts.show_js:
|
||||
self.show_js(js)
|
||||
print ('#'*80)
|
||||
print ('#'*80)
|
||||
|
||||
def clean(self):
|
||||
for toplevel, dest in self.COFFEE_DIRS.iteritems():
|
||||
|
|
|
|||
Loading…
Reference in a new issue