Skip to content

Instantly share code, notes, and snippets.

@allieus
Created June 26, 2013 05:07
Show Gist options
  • Save allieus/5864923 to your computer and use it in GitHub Desktop.
Save allieus/5864923 to your computer and use it in GitHub Desktop.
coffeescript 파일 변경 시에, 자동 빌드 수행
# coding: utf-8
import os
import time
files = {}
def check():
global files
for root, dirnames, filenames in os.walk('.'):
for filename in filenames:
filepath = os.path.join(root, filename)
ext = os.path.splitext(filepath)[-1].lower()
if ext == '.coffee':
current_mtime = os.path.getmtime(filepath)
changed = False
if filepath in files:
if current_mtime > files[filepath]:
changed = True
else:
changed = True
files[filepath] = current_mtime
if changed:
print 'compile %s ...' % filepath
os.system('coffee --compile "%s"' % filepath)
if __name__ == '__main__':
while True:
try:
time.sleep(1)
check()
except KeyboardInterrupt:
print 'KeyboardInterrupt.'
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment