-
-
Notifications
You must be signed in to change notification settings - Fork 370
/
Copy pathcoffee.py
30 lines (22 loc) · 908 Bytes
/
coffee.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
from __future__ import unicode_literals
import os
from pipeline.conf import settings
from pipeline.compilers import SubProcessCompiler
class CoffeeScriptCompiler(SubProcessCompiler):
output_extension = 'js'
def match_file(self, path):
return path.endswith('.coffee') or path.endswith('.litcoffee')
def compile_file(self, infile, outfile, outdated=False, force=False):
if not outdated and not force:
return # File doesn't need to be recompiled
args = list(settings.COFFEE_SCRIPT_ARGUMENTS)
if settings.OUTPUT_SOURCEMAPS and not(set(args) & set(['-m', '--map'])):
args.append('--map')
command = (
settings.COFFEE_SCRIPT_BINARY,
"-c",
"-o", os.path.dirname(outfile),
args,
infile,
)
return self.execute_command(command, cwd=os.path.dirname(outfile))