-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoffee.py
41 lines (33 loc) · 1 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
import subprocess
import sys
import os
import glob
import re
def coffee(js_dir, coffee_dir):
args = ['coffee', '--bare']
args += ['-o', js_dir]
args += ['-c', coffee_dir]
subprocess.call(args)
def getCommonArgs(closure_library_path):
args = ['python', os.path.join(closure_library_path, 'closure/bin/calcdeps.py')]
args += ['--dep', os.path.join(closure_library_path, 'closure/goog/base.js')]
args += ["-o", "deps"]
return args
def generate_deps(closure_library_path, js_dirs, deps_path):
args = getCommonArgs(closure_library_path)
for dir in js_dirs:
args += ['-p', dir]
args += ["--output_file", deps_path]
subprocess.call(args)
def removeOrphanedJs(diff):
# remove corresponding js files
if(diff.has_key('removed')):
removed = diff['removed']
print removed
for file in removed:
file = re.sub('coffee/', 'js/', file)
file = re.sub('\.coffee$', '\.js', file)
if os.path.exists(file):
print 'removing ' + file
os.remove(file)
print file