fix 'tzk convert' failing when outside source directory

I only tested it with '.' as the source for some reason, so missed this.
This commit is contained in:
Soren I. Bjornstad 2021-09-21 12:21:27 -05:00
parent 39df530ec2
commit 1304d8edc2
2 changed files with 10 additions and 4 deletions

View File

@ -300,7 +300,7 @@ class ConvertCommand(CliCommand):
if not os.path.exists(args.source):
fail(f"The source location '{args.source}' does not exist.")
if os.path.exists(args.destination) and not args.force:
fail(f"The destination location '{args.source}' already exists. "
fail(f"The destination location '{args.destination}' already exists. "
f"(Use --force to overwrite it.)")
@ -325,14 +325,14 @@ class ConvertCommand(CliCommand):
"a tzk_config.py file.")
with pushd(str(source)):
source_wiki_folder = cm().wiki_folder
source_wiki_folder = Path.cwd() / cm(cache=[]).wiki_folder
tw.exec(
(
("output", str(destination.parent)),
("render", "$:/core/save/all", destination.name, "text/plain"),
),
base_wiki_folder=source_wiki_folder
base_wiki_folder=str(source_wiki_folder)
)
# Conversion from file to folder using --savewikifolder.

View File

@ -44,7 +44,13 @@ def exec(args: Sequence[Sequence[str]], base_wiki_folder: str = None) -> int:
during the execution of builders,
unless explicitly changed.
"""
call_args = [_tw_path()]
# must pushd into base wiki to find the tiddlywiki node_modules
if base_wiki_folder is not None:
with pushd(base_wiki_folder):
call_args = [_tw_path()]
else:
call_args = [_tw_path()]
if base_wiki_folder is not None:
call_args.append(base_wiki_folder)
for tw_arg in args: