NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Run All Scripts In A Directory Recursively In Rust

I'm expermenting with an idea of including executable scripts in the main content directory for my Neopolitan implementation. The idea is to use them for preflight by running them before each build. That allows functionality to be added without having to mess with the main binary.

This is the code I'm using to loop down the direcotry structure and run the files:

April 2023
use std::path::PathBuf;
use std::process::Command;
use walkdir::Error;
use walkdir::WalkDir;

pub fn run_preflight() -> Result<(), Error> {
    for entry in WalkDir::new("./site/content").sort_by_file_name() {
        let path = PathBuf::from(entry?.path());
        if let Some(ext) = path.extension() {
            if ext == "py" {
                let path_string = path.display().to_string();
                let args: Vec<&str> = vec![path_string.as_str()];
                let cmd_output = Command::new("/opt/homebrew/bin/python3")
═══ § ═══