mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +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
24
setupbase.py
24
setupbase.py
@ -470,17 +470,27 @@ class JavascriptVersion(Command):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
|
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
|
||||||
|
lines = []
|
||||||
|
found = False
|
||||||
with open(nsfile) as f:
|
with open(nsfile) as f:
|
||||||
lines = f.readlines()
|
for line in f.readlines():
|
||||||
with open(nsfile, 'w') as f:
|
|
||||||
found = False
|
|
||||||
for line in lines:
|
|
||||||
if line.strip().startswith("Jupyter.version"):
|
if line.strip().startswith("Jupyter.version"):
|
||||||
line = ' Jupyter.version = "{0}";\n'.format(version)
|
|
||||||
found = True
|
found = True
|
||||||
|
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)
|
f.write(line)
|
||||||
if not found:
|
|
||||||
raise RuntimeError("Didn't find Jupyter.version line in %s" % nsfile)
|
|
||||||
|
|
||||||
|
|
||||||
def css_js_prerelease(command, strict=False):
|
def css_js_prerelease(command, strict=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user