forked from FallingColors/hexdummy
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoxfile.py
61 lines (49 loc) · 1.39 KB
/
noxfile.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
from pathlib import Path
import shutil
import stat
from typing import Any
import nox
nox.options.reuse_existing_virtualenvs = True
@nox.session
def book(session: nox.Session):
session.install("copier", "copier-template-tester")
root = Path(".ctt/defaults")
if root.is_dir():
session.log(f"Removing directory: {root}")
shutil.rmtree(root, onerror=on_rm_error)
session.run("ctt", silent=True)
with session.chdir(root):
session.run(
"git",
"init",
external=True,
silent=True,
)
session.run(
"git",
"commit",
"--allow-empty",
"-m",
"Initial commit",
external=True,
silent=True,
)
session.run(
"copier",
"copy",
"gh:hexdoc-dev/hexdoc-hexcasting-template",
".",
"--answers-file",
".hexdoc-template-inputs.yml",
"--skip",
".gitignore",
"--defaults",
silent=True,
)
session.install(".[dev]")
session.run("hexdoc", "serve")
def on_rm_error(func: Any, path: str, exc_info: Any):
# from: https://stackoverflow.com/questions/4829043/how-to-remove-read-only-attrib-directory-with-python-in-windows
path_ = Path(path)
path_.chmod(stat.S_IWRITE)
path_.unlink()