File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 3030import pprint
3131import xml .dom .minidom
3232import random
33+ import contextlib
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 33
44class 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
911def main ():
You can’t perform that action at this time.
0 commit comments