fix(typst): Skip typst when self-update is disabled (#1397)

This commit is contained in:
Gideon
2025-11-01 14:53:26 +01:00
committed by GitHub
parent dd6bc580fa
commit e01be14041
3 changed files with 52 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ use jetbrains_toolbox_updater::{find_jetbrains_toolbox, update_jetbrains_toolbox
use regex::bytes::Regex;
use rust_i18n::t;
use semver::Version;
use serde::Deserialize;
use std::ffi::OsString;
use std::iter::once;
use std::path::PathBuf;
@@ -1779,9 +1780,40 @@ pub fn run_yazi(ctx: &ExecutionContext) -> Result<()> {
ctx.execute(ya).args(["pkg", "upgrade"]).status_checked()
}
#[derive(Deserialize)]
struct TypstInfo {
build: TypstBuild,
}
#[derive(Deserialize)]
struct TypstBuild {
settings: TypstSettings,
}
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
struct TypstSettings {
self_update: bool,
}
pub fn run_typst(ctx: &ExecutionContext) -> Result<()> {
let typst = require("typst")?;
let raw_info = ctx
.execute(&typst)
.args(["info", "-f", "json"])
.output_checked_utf8()?
.stdout;
let info: TypstInfo = serde_json::from_str(&raw_info).wrap_err_with(|| {
output_changed_message!(
"typst info -f json",
"json output invalid or does not contain .build.settings.self-update"
)
})?;
if !info.build.settings.self_update {
return Err(SkipStep("This build of typst does not have self-update enabled".to_string()).into());
}
print_separator("Typst");
ctx.execute(typst).args(["update"]).status_checked()