Load all monologues in wasm build (hopefully) by loading each one by one
parent
b1832b6349
commit
1c7dba07c0
@ -1,40 +1,59 @@
|
|||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
{
|
write_version_file();
|
||||||
use chrono::prelude::*;
|
|
||||||
use std::fs::File;
|
write_monologues_file();
|
||||||
use std::io::Write;
|
}
|
||||||
use std::process::Command;
|
|
||||||
|
fn write_version_file() {
|
||||||
// Date of build
|
use chrono::prelude::*;
|
||||||
let now = Utc::now().format("%Y%m%d%H%M%S");
|
use std::process::Command;
|
||||||
|
|
||||||
// Latest commit ID
|
// Date of build
|
||||||
let git_sha = String::from_utf8(
|
let now = Utc::now().format("%Y%m%d%H%M%S");
|
||||||
Command::new("git")
|
|
||||||
.arg("rev-parse")
|
// Latest commit ID
|
||||||
.arg("--short")
|
let git_sha = String::from_utf8(
|
||||||
.arg("HEAD")
|
Command::new("git")
|
||||||
.output()
|
.arg("rev-parse")
|
||||||
.expect("Failed to get git sha")
|
.arg("--short")
|
||||||
.stdout,
|
.arg("HEAD")
|
||||||
)
|
.output()
|
||||||
.expect("Read stdout from git sha command");
|
.expect("Failed to get git sha")
|
||||||
|
.stdout,
|
||||||
// If the workspace is dirty or clean
|
)
|
||||||
let clean = Command::new("git")
|
.expect("Read stdout from git sha command");
|
||||||
.arg("diff")
|
|
||||||
.arg("--quiet")
|
// If the workspace is dirty or clean
|
||||||
.status()
|
let clean = Command::new("git")
|
||||||
.expect("Failed to run git diff")
|
.arg("diff")
|
||||||
.success();
|
.arg("--quiet")
|
||||||
|
.status()
|
||||||
let mut file = File::create("VERSION").expect("Create VERSION file");
|
.expect("Failed to run git diff")
|
||||||
|
.success();
|
||||||
if clean {
|
|
||||||
write!(file, "0.0.0-{now}+{}", git_sha.trim()).expect("Write version to VERSION file");
|
let mut file = File::create("VERSION").expect("Create VERSION file");
|
||||||
} else {
|
|
||||||
write!(file, "0.0.0-{now}+{}-dirty", git_sha.trim())
|
if clean {
|
||||||
.expect("Write version to VERSION file");
|
write!(file, "0.0.0-{now}+{}", git_sha.trim()).expect("Write version to VERSION file");
|
||||||
}
|
} else {
|
||||||
|
write!(file, "0.0.0-{now}+{}-dirty", git_sha.trim())
|
||||||
|
.expect("Write version to VERSION file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_monologues_file() {
|
||||||
|
let mut file = File::create("assets/trees/MONOLOGUES").expect("Create MONOLOGUES file");
|
||||||
|
|
||||||
|
walkdir::WalkDir::new("assets/trees")
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|entry| entry.ok())
|
||||||
|
.filter(|entry| {
|
||||||
|
entry.path().extension() == Some(std::ffi::OsStr::new("mono"))
|
||||||
|
})
|
||||||
|
.for_each(|entry| {
|
||||||
|
let _ = writeln!(file, "{}", entry.path().to_string_lossy().strip_prefix("assets/").unwrap());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue