forked from elm/compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
executable file
·48 lines (30 loc) · 1.14 KB
/
check.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
42
43
44
45
46
47
48
#!/usr/bin/env python
import os
import sys
## FIGURE OUT NEW MODIFICATION TIME
def mostRecentModification(directory):
mostRecent = 0
for dirpath, dirs, files in os.walk(directory):
for f in files:
lastModified = os.path.getmtime(dirpath + '/' + f)
mostRecent = max(int(lastModified), mostRecent)
return mostRecent
srcTime = mostRecentModification('ui/src')
assetTime = mostRecentModification('ui/assets')
mostRecent = max(srcTime, assetTime)
## FIGURE OUT OLD MODIFICATION TIME
with open('ui/last-modified', 'a') as handle:
pass
prevMostRecent = 0
with open('ui/last-modified', 'r+') as handle:
line = handle.read()
prevMostRecent = int(line) if line else 0
## TOUCH FILES IF NECESSARY
if mostRecent > prevMostRecent:
print "+------------------------------------------------------------+"
print "| Some ui/ code changed. Touching src/Reactor/StaticFiles.hs |"
print "| to trigger a recompilation of the Template Haskell stuff. |"
print "+------------------------------------------------------------+"
os.utime('src/Reactor/StaticFiles.hs', None)
with open('ui/last-modified', 'w') as handle:
handle.write(str(mostRecent))