Fix i18n build script not responding to env var changes
Not much use declaring the cargo flag when we bake the env var into the binary! Also treat an empty variable as missing.
This commit is contained in:
parent
32d6248ff1
commit
e835922ded
@ -1,5 +1,4 @@
|
||||
[env]
|
||||
# STRINGS_JSON = { value = "out/rslib/i18n/strings.json", relative = true }
|
||||
STRINGS_PY = { value = "out/pylib/anki/_fluent.py", relative = true }
|
||||
STRINGS_JS = { value = "out/ts/lib/ftl.js", relative = true }
|
||||
STRINGS_DTS = { value = "out/ts/lib/ftl.d.ts", relative = true }
|
||||
|
@ -8,7 +8,8 @@ mod python;
|
||||
mod typescript;
|
||||
mod write_strings;
|
||||
|
||||
use std::path::Path;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anki_io::create_dir_all;
|
||||
use anki_io::write_file_if_changed;
|
||||
@ -32,10 +33,13 @@ fn main() -> Result<()> {
|
||||
|
||||
// write strings.json file to requested path
|
||||
println!("cargo:rerun-if-env-changed=STRINGS_JSON");
|
||||
if let Some(path) = option_env!("STRINGS_JSON") {
|
||||
let meta_json = serde_json::to_string_pretty(&modules).unwrap();
|
||||
create_dir_all(Path::new(path).parent().unwrap())?;
|
||||
write_file_if_changed(path, meta_json)?;
|
||||
if let Ok(path) = env::var("STRINGS_JSON") {
|
||||
if !path.is_empty() {
|
||||
let path = PathBuf::from(path);
|
||||
let meta_json = serde_json::to_string_pretty(&modules).unwrap();
|
||||
create_dir_all(path.parent().unwrap())?;
|
||||
write_file_if_changed(path, meta_json)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user