mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Fail gracefully if git
does not exist
This commit is contained in:
parent
b934a2fd83
commit
a6b63b96f9
14
cli/build.rs
14
cli/build.rs
@ -1,9 +1,11 @@
|
|||||||
use std::error::Error;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() {
|
||||||
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output()?;
|
let version = Command::new("git")
|
||||||
let hash = std::str::from_utf8(&output.stdout)?;
|
.args(&["rev-parse", "HEAD"])
|
||||||
println!("cargo:rustc-env=TYPST_HASH={}", &hash[..8]);
|
.output()
|
||||||
Ok(())
|
.ok()
|
||||||
|
.and_then(|output| String::from_utf8(output.stdout[..8].into()).ok())
|
||||||
|
.unwrap_or_else(|| "(unknown version)".into());
|
||||||
|
println!("cargo:rustc-env=TYPST_VERSION={version}");
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ fn print_help(help: &'static str) -> ! {
|
|||||||
|
|
||||||
/// Print the version hash and quit.
|
/// Print the version hash and quit.
|
||||||
fn print_version() -> ! {
|
fn print_version() -> ! {
|
||||||
println!("typst {}", env!("TYPST_HASH"));
|
println!("typst {}", env!("TYPST_VERSION"));
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user