Skip to content

Commit

Permalink
Fix panic on absent build dir + add build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswhybrow committed Oct 3, 2023
1 parent dd60d66 commit f063dec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/configure-pages@v3
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: experimental-features = nix-command flakes
- uses: actions/checkout@v3
- uses: actions/configure-pages@v3
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix run
- uses: actions/[email protected]
with:
Expand Down
13 changes: 4 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,8 @@ fn copy_dir(input_path: &PathBuf, output_path: &PathBuf) {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();

let input = Path::new(&args.input)
.canonicalize()
.expect("Input path not found");

let output = Path::new(&args.output)
.canonicalize()
.expect("Output path not found");
let input = Path::new(&args.input);
let output = Path::new(&args.output);

let cache_path = Path::new(&args.cache_path);

Expand All @@ -314,7 +309,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
if args.build_cache {
println!(" Building cache of web scraped data...");
let mut scraper = Scraper::new_scraper(cache_path.to_path_buf());
parse_input_files(input, &mut scraper);
parse_input_files(input.to_path_buf(), &mut scraper);
scraper.into_cache().await;
println!(" Built cache at {:?}", cache_path);
return Ok(())
Expand Down Expand Up @@ -347,7 +342,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

println!("\nWriting Files");

let input_file_results = parse_input_files(input, &mut Scraper::new_fulfiller(cache_path.to_path_buf()));
let input_file_results = parse_input_files(input.to_path_buf(), &mut Scraper::new_fulfiller(cache_path.to_path_buf()));

for (input_file, ast, _mentions, _issues) in input_file_results.iter() {
render(&output.join(format!("{}/index.html", input_file.slug)), markup::new! {
Expand Down

0 comments on commit f063dec

Please sign in to comment.