Skip to content

Commit

Permalink
fix(build): canonicalize file arguments
Browse files Browse the repository at this point in the history
fixes #98
  • Loading branch information
fiji-flo committed Jan 28, 2025
1 parent 797e299 commit 5e2cccf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions crates/rari-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ fn main() -> Result<(), Error> {
settings.json_issues = args.json_issues;
let _ = SETTINGS.set(settings);

let arg_files = args
.files
.iter()
.map(|path| path.canonicalize())
.collect::<Result<Vec<PathBuf>, _>>()?;

let templ_stats = if args.templ_stats {
let (tx, rx) = channel::<String>();
TEMPL_RECORDER_SENDER
Expand Down Expand Up @@ -303,7 +309,7 @@ fn main() -> Result<(), Error> {
None
};

let cache = match (args.files.is_empty(), args.no_cache) {
let cache = match (arg_files.is_empty(), args.no_cache) {
(_, true) => Cache::None,
(true, false) => Cache::Static,
(false, false) => Cache::Dynamic,
Expand All @@ -315,10 +321,10 @@ fn main() -> Result<(), Error> {
let mut urls = Vec::new();
let mut docs = Vec::new();
info!("Building everything 🛠️");
if args.all || !args.no_basic || args.content || !args.files.is_empty() {
if args.all || !args.no_basic || args.content || !arg_files.is_empty() {
let start = std::time::Instant::now();
docs = if !args.files.is_empty() {
read_docs_parallel::<Page, Doc>(&args.files, None)?
docs = if !arg_files.is_empty() {
read_docs_parallel::<Page, Doc>(&arg_files, None)?
} else if args.no_cache {
let files: &[_] = if let Some(translated_root) = content_translated_root() {
&[content_root(), translated_root]
Expand All @@ -342,7 +348,7 @@ fn main() -> Result<(), Error> {
urls.extend(spas);
info!("Took: {: >10.3?} to build spas ({num})", start.elapsed(),);
}
if args.all || !args.no_basic || args.content || !args.files.is_empty() {
if args.all || !args.no_basic || args.content || !arg_files.is_empty() {
let start = std::time::Instant::now();
let (docs, meta) = build_docs(&docs)?;
build_top_level_meta(meta)?;
Expand Down

0 comments on commit 5e2cccf

Please sign in to comment.