Created
September 1, 2020 13:56
-
-
Save saiumesh535/8be1f48fc31679ab0c61bf7d67bc4a6c to your computer and use it in GitHub Desktop.
react-cli.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use include_dir::{include_dir, Dir}; | |
use std::fs::create_dir_all; | |
use std::path::Path; | |
use std::{time, io::prelude::*}; | |
const PROJECT_DIR: Dir = include_dir!("./server"); | |
fn main() { | |
let now = time::Instant::now(); | |
let start_path = Path::new("temp"); | |
create_dir_all(start_path).unwrap(); | |
for f in PROJECT_DIR.find("**").unwrap() { | |
// if f.path().display().to_string() == "" { | |
// continue; | |
// } | |
if PROJECT_DIR.get_dir(f.path()).is_some() { | |
create_dir_all(start_path.join(f.path())).unwrap(); | |
} | |
if PROJECT_DIR.get_file(f.path()).is_some() { | |
let content = PROJECT_DIR.get_file(f.path()).unwrap().contents_utf8().unwrap(); | |
std::fs::File::create(start_path.join(f.path())).unwrap().write_all(content.as_bytes()).unwrap(); | |
} | |
} | |
println!("finished in {}", now.elapsed().as_secs()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment