@@ -7,13 +7,14 @@ pub use error::OgImageError;
77
88use crate :: formatting:: { serialize_bytes, serialize_number, serialize_optional_number} ;
99use bytes:: Bytes ;
10- use crates_io_env_vars:: var ;
10+ use crates_io_env_vars:: var_parsed ;
1111use serde:: Serialize ;
1212use std:: collections:: HashMap ;
1313use std:: path:: PathBuf ;
1414use tempfile:: NamedTempFile ;
1515use tokio:: fs;
1616use tokio:: process:: Command ;
17+ use tracing:: debug;
1718
1819/// Data structure containing information needed to generate an OpenGraph image
1920/// for a crates.io crate.
@@ -109,19 +110,26 @@ impl OgImageGenerator {
109110 /// # Ok::<(), crates_io_og_image::OgImageError>(())
110111 /// ```
111112 pub fn from_environment ( ) -> Result < Self , OgImageError > {
112- let typst_path = var ( "TYPST_PATH" ) . map_err ( OgImageError :: EnvVarError ) ?;
113- let font_path = var ( "TYPST_FONT_PATH" ) . map_err ( OgImageError :: EnvVarError ) ?;
114-
115- let mut generator = if let Some ( path) = typst_path {
116- Self :: new ( PathBuf :: from ( path) )
113+ let typst_path = var_parsed :: < PathBuf > ( "TYPST_PATH" ) ;
114+ let typst_path = typst_path. map_err ( OgImageError :: EnvVarError ) ?;
115+ let font_path = var_parsed :: < PathBuf > ( "TYPST_FONT_PATH" ) ;
116+ let font_path = font_path. map_err ( OgImageError :: EnvVarError ) ?;
117+
118+ let mut generator = if let Some ( typst_path) = typst_path {
119+ debug ! ( "Using TYPST_PATH: {}" , typst_path. display( ) ) ;
120+ Self :: new ( typst_path)
117121 } else {
122+ debug ! ( "TYPST_PATH not set, using default 'typst' binary in PATH" ) ;
118123 Self :: default ( )
119124 } ;
120125
121126 if let Some ( font_path) = font_path {
122127 let current_dir = std:: env:: current_dir ( ) ?;
123128 let font_path = current_dir. join ( font_path) . canonicalize ( ) ?;
129+ debug ! ( "Using TYPST_FONT_PATH: {}" , font_path. display( ) ) ;
124130 generator = generator. with_font_path ( font_path) ;
131+ } else {
132+ debug ! ( "TYPST_FONT_PATH not set, using default font discovery" ) ;
125133 }
126134
127135 Ok ( generator)
0 commit comments