-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
42 lines (36 loc) · 1.05 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
# SPDX-FileCopyrightText: Common Ground Electronics <https://cgnd.dev>
#
# SPDX-License-Identifier: MIT OR Apache-2.0
import sys
if sys.version_info >= (3, 11):
import inspect
if not hasattr(inspect, "getargspec"):
inspect.getargspec = inspect.getfullargspec
from invoke import task
@task(
auto_shortflags=False,
)
def preview(
context,
fast_render=False,
build_drafts=True,
build_future=True,
# default bind address is 127.0.0.1, 0.0.0.0 enables preview from other
# devices (e.g. mobile devices) on the same network.
bind_addr="0.0.0.0", # nosec
base_url="",
port="",
):
cmd = " ".join(
[
"hugo",
"server",
"" if fast_render else "--disableFastRender",
"--buildDrafts" if build_drafts else "",
"--buildFuture" if build_future else "",
f'--bind="{bind_addr}"' if bind_addr else "",
f'--baseURL="{base_url}"' if base_url else "",
f'--port="{port}"' if port else "",
]
)
context.run(cmd)