mirror of
https://github.com/venthur/blag.git
synced 2025-11-26 05:02:58 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db30fe1d06 | ||
|
|
27a760d834 | ||
|
|
a9abcd753a | ||
|
|
3deb62ed88 | ||
|
|
2366a2ae86 | ||
|
|
0fb01e3249 | ||
|
|
78316725cf | ||
|
|
4f1632e3cd | ||
|
|
d23f3666dc | ||
|
|
60cfd0290a | ||
|
|
10ea8df1ac | ||
|
|
edc89581af | ||
|
|
6d75891ace | ||
|
|
6367f5a55a | ||
|
|
3cd316a537 | ||
|
|
3b8d2fe9d6 | ||
|
|
1fe576a771 | ||
|
|
2f4d2267a0 | ||
|
|
7bb51ff060 | ||
|
|
5a8012d62b |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,6 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [1.1.0] - 2021-1006
|
## [1.2.0] - 2021-11-06
|
||||||
|
|
||||||
|
* `make serve` now rebuilds immediately once after called to avoid serving
|
||||||
|
stale files
|
||||||
|
* updated dependencies:
|
||||||
|
* feedgenerator 2.0.0
|
||||||
|
* jinja2 3.0.1
|
||||||
|
* pytest-cov 3.0.0
|
||||||
|
* flake8 4.0.1
|
||||||
|
* twine 3.5.0
|
||||||
|
|
||||||
|
## [1.1.0] - 2021-10-06
|
||||||
|
|
||||||
* added Python 3.10 to list of supported versions to test against
|
* added Python 3.10 to list of supported versions to test against
|
||||||
* added dependabot to github workflows
|
* added dependabot to github workflows
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ def autoreload(args):
|
|||||||
last modified time). If the last modified time has changed, a
|
last modified time). If the last modified time has changed, a
|
||||||
rebuild is triggered.
|
rebuild is triggered.
|
||||||
|
|
||||||
|
A rebuild is also performed immediately when this method is called
|
||||||
|
to avoid serving stale contents.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
args : argparse.Namespace
|
args : argparse.Namespace
|
||||||
@@ -62,12 +65,14 @@ def autoreload(args):
|
|||||||
"""
|
"""
|
||||||
dirs = [args.input_dir, args.template_dir, args.static_dir]
|
dirs = [args.input_dir, args.template_dir, args.static_dir]
|
||||||
logger.info(f'Monitoring {dirs} for changes...')
|
logger.info(f'Monitoring {dirs} for changes...')
|
||||||
last_mtime = get_last_modified(dirs)
|
# make sure we trigger the rebuild immediately when we enter the
|
||||||
|
# loop to avoid serving stale contents
|
||||||
|
last_mtime = 0
|
||||||
while True:
|
while True:
|
||||||
mtime = get_last_modified(dirs)
|
mtime = get_last_modified(dirs)
|
||||||
if mtime > last_mtime:
|
if mtime > last_mtime:
|
||||||
last_mtime = mtime
|
last_mtime = mtime
|
||||||
logger.debug('Change detected, rebuilding...')
|
logger.info('Change detected, rebuilding...')
|
||||||
blag.build(args)
|
blag.build(args)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
@@ -84,4 +89,5 @@ def serve(args):
|
|||||||
directory=args.output_dir))
|
directory=args.output_dir))
|
||||||
proc = multiprocessing.Process(target=autoreload, args=(args,))
|
proc = multiprocessing.Process(target=autoreload, args=(args,))
|
||||||
proc.start()
|
proc.start()
|
||||||
|
logger.info("\n\n Devserver Started -- visit http://localhost:8000\n")
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__VERSION__ = '1.1.0'
|
__VERSION__ = '1.2.0'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
sphinx==4.2.0
|
sphinx==4.2.0
|
||||||
twine==3.4.2
|
twine==3.5.0
|
||||||
wheel==0.37.0
|
wheel==0.37.0
|
||||||
pytest==6.2.5
|
pytest==6.2.5
|
||||||
pytest-cov==2.12.1
|
pytest-cov==3.0.0
|
||||||
flake8==3.9.2
|
flake8==4.0.1
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
markdown==3.3.4
|
markdown==3.3.4
|
||||||
feedgenerator==1.9.2
|
feedgenerator==2.0.0
|
||||||
jinja2==3.0.1
|
jinja2==3.0.2
|
||||||
pygments==2.10.0
|
pygments==2.10.0
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from blag import devserver
|
from blag import devserver
|
||||||
|
|
||||||
@@ -19,3 +22,45 @@ def test_get_last_modified(cleandir):
|
|||||||
|
|
||||||
assert t2 > t1
|
assert t2 > t1
|
||||||
assert t2 == t3
|
assert t2 == t3
|
||||||
|
|
||||||
|
|
||||||
|
def test_autoreload_builds_immediately(args):
|
||||||
|
# create a dummy file that can be build
|
||||||
|
with open('content/test.md', 'w') as fh:
|
||||||
|
fh.write('boo')
|
||||||
|
|
||||||
|
t = threading.Thread(target=devserver.autoreload,
|
||||||
|
args=(args, ),
|
||||||
|
daemon=True,)
|
||||||
|
t0 = devserver.get_last_modified(['build'])
|
||||||
|
t.start()
|
||||||
|
# try for 5 seconds...
|
||||||
|
for i in range(5):
|
||||||
|
time.sleep(1)
|
||||||
|
t1 = devserver.get_last_modified(['build'])
|
||||||
|
print(t1)
|
||||||
|
if t1 > t0:
|
||||||
|
break
|
||||||
|
assert t1 > t0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.filterwarnings("ignore::pytest.PytestUnhandledThreadExceptionWarning") # noqa
|
||||||
|
def test_autoreload(args):
|
||||||
|
t = threading.Thread(target=devserver.autoreload,
|
||||||
|
args=(args, ),
|
||||||
|
daemon=True,)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
t0 = devserver.get_last_modified(['build'])
|
||||||
|
|
||||||
|
# create a dummy file that can be build
|
||||||
|
with open('content/test.md', 'w') as fh:
|
||||||
|
fh.write('boo')
|
||||||
|
|
||||||
|
# try for 5 seconds to see if we rebuild once...
|
||||||
|
for i in range(5):
|
||||||
|
time.sleep(1)
|
||||||
|
t1 = devserver.get_last_modified(['build'])
|
||||||
|
if t1 > t0:
|
||||||
|
break
|
||||||
|
assert t1 > t0
|
||||||
|
|||||||
Reference in New Issue
Block a user