Created
June 26, 2013 05:07
-
-
Save allieus/5864923 to your computer and use it in GitHub Desktop.
coffeescript 파일 변경 시에, 자동 빌드 수행
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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