Skip to content

Commit 2f962c3

Browse files
committed
🐛 Run npm link in package directory
1 parent 515748c commit 2f962c3

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

adoc_math/_common/a_imports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
import pprint
3131
import xml.dom.minidom
3232
import random
33+
import contextlib

adoc_math/_common/e_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,16 @@ def join_with(
8787
"""Reverses the arguments of x.join(y)"""
8888

8989
return joiner.join(it)
90+
91+
92+
@contextlib.contextmanager
93+
def change_cwd(path: Union[plib.Path, str]):
94+
"""
95+
Temporary change the current working directory to the path provided as the first argument.
96+
"""
97+
orig_cwd = plib.Path.cwd().resolve()
98+
try:
99+
os.chdir(plib.Path(path).resolve())
100+
yield
101+
finally:
102+
os.chdir(orig_cwd)

adoc_math/_setup/b_link.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
class Link:
55
def run(s):
6-
run_cmd(cmd=Command("npm link mathjax@3"))
6+
install_dir = plib.Path(__file__).parent.parent.parent
7+
with change_cwd(install_dir):
8+
run_cmd(cmd=Command("npm link mathjax@3"))
79

810

911
def main():

0 commit comments

Comments
 (0)