Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Created September 1, 2020 13:56
Show Gist options
  • Save saiumesh535/8be1f48fc31679ab0c61bf7d67bc4a6c to your computer and use it in GitHub Desktop.
Save saiumesh535/8be1f48fc31679ab0c61bf7d67bc4a6c to your computer and use it in GitHub Desktop.
react-cli.rs
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