Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
adjust root logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Enter-tainer committed Aug 6, 2023
1 parent 487ed55 commit 9dad872
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,24 @@ async fn main() {
let doc_publisher: Publisher<Document> = PublisherImpl::new().into();
let command = CompileSettings::with_arguments(arguments.clone());
let enable_partial_rendering = arguments.enable_partial_rendering;
let (root, entry) = if let Some(root) = &command.root {
(root.clone(), command.input.clone())
let entry = if command.input.is_absolute() {
command.input.clone()
} else {
let input_path = command.input.canonicalize().unwrap();
let root = input_path.parent().unwrap().to_owned();
(root, input_path)
std::env::current_dir().unwrap().join(command.input)
};
let root = if let Some(root) = &command.root {
if root.is_absolute() {
root.clone()
} else {
std::env::current_dir().unwrap().join(root)
}
} else {
std::env::current_dir().unwrap()
};
if !entry.starts_with(&root) {
error!("entry file must be in the root directory");
std::process::exit(1);
}
let compile_driver = {
let world = TypstSystemWorld::new(CompileOpts {
root_dir: root.clone(),
Expand Down

0 comments on commit 9dad872

Please sign in to comment.