mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-18 11:55:46 +08:00
only write file in jsversion if there's a change to make
avoids updating the file's mtime unnecessarily, forcing a rebuild
This commit is contained in:
parent
fdc1bb50da
commit
d7a0aba848
22
setupbase.py
22
setupbase.py
@ -470,18 +470,28 @@ class JavascriptVersion(Command):
|
||||
|
||||
def run(self):
|
||||
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
|
||||
with open(nsfile) as f:
|
||||
lines = f.readlines()
|
||||
with open(nsfile, 'w') as f:
|
||||
lines = []
|
||||
found = False
|
||||
for line in lines:
|
||||
with open(nsfile) as f:
|
||||
for line in f.readlines():
|
||||
if line.strip().startswith("Jupyter.version"):
|
||||
line = ' Jupyter.version = "{0}";\n'.format(version)
|
||||
found = True
|
||||
f.write(line)
|
||||
new_line = ' Jupyter.version = "{0}";\n'.format(version)
|
||||
if new_line == line:
|
||||
# no change, don't rewrite file
|
||||
return
|
||||
lines.append(new_line)
|
||||
else:
|
||||
lines.append(line)
|
||||
|
||||
if not found:
|
||||
raise RuntimeError("Didn't find Jupyter.version line in %s" % nsfile)
|
||||
|
||||
print("Writing version=%s to %s" % (version, nsfile))
|
||||
with open(nsfile, 'w') as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
|
||||
|
||||
def css_js_prerelease(command, strict=False):
|
||||
"""decorator for building minified js/css prior to another command"""
|
||||
|
Loading…
Reference in New Issue
Block a user