-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
63 lines (44 loc) · 1.03 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
51
52
53
54
55
56
57
58
59
60
61
62
63
import contextlib
import os
from pathlib import Path
from invoke import task
# context manager that make sure subsequent
# commands are run in the specified directory
@contextlib.contextmanager
def cwd(rel_path: str):
prev_cwd = os.getcwd()
try:
os.chdir(Path(__file__).parent / rel_path)
yield
finally:
os.chdir(prev_cwd)
@task
def hello(_):
print("Hello, world!")
@task
def install(c):
with cwd("observable"):
c.run("yarn install")
@task
def build(c):
with cwd("observable"):
c.run("yarn build")
@task
def dev(c):
with cwd("observable"):
c.run("yarn dev")
@task
def deploy(c):
with cwd("observable"):
c.run("yarn deploy")
@task
def clean_branches(c):
c.run("git branch | grep -v 'main' | xargs git branch -D")
@task
def touch(c):
with cwd("observable/docs/data"):
c.run("touch graph.sqlite.py")
@task
def fetch(c, count: int = 5):
with cwd("."):
c.run(f"python scripts/fetch_custom_institutions.py hbcus {count}")