forked from ImperialCollegeLondon/FLT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
50 lines (42 loc) · 1.33 KB
/
tasks.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
49
50
import os
import shutil
import subprocess
from pathlib import Path
from invoke import run, task
from blueprint.tasks import web, bp, print_bp, serve
ROOT = Path(__file__).parent
BP_DIR = ROOT/'blueprint'
@task(bp, web)
def all(ctx):
shutil.rmtree(ROOT/'docs'/'blueprint', ignore_errors=True)
shutil.copytree(ROOT/'blueprint'/'web', ROOT/'docs'/'blueprint')
shutil.copy2(ROOT/'blueprint'/'print'/'print.pdf', ROOT/'docs'/'blueprint.pdf')
@task(web)
def html(ctx):
shutil.rmtree(ROOT/'docs'/'blueprint', ignore_errors=True)
shutil.copytree(ROOT/'blueprint'/'web', ROOT/'docs'/'blueprint')
@task(bp, web)
def dev(ctx):
"""
Serve the blueprint website, rebuild PDF and the website on file changes
"""
from watchfiles import run_process, DefaultFilter
def callback(changes):
print('Changes detected:', changes)
bp(ctx)
web(ctx)
run_process(BP_DIR/'src', target='inv serve', callback=callback,
watch_filter=DefaultFilter(
ignore_entity_patterns=(
'.*\.aux$',
'.*\.log$',
'.*\.fls$',
'.*\.fdb_latexmk$',
'.*\.bbl$',
'.*\.paux$',
'.*\.pdf$',
'.*\.out$',
'.*\.blg$',
'.*\.synctex.*$',
)
))