Skip to content

Commit 99c96ba

Browse files
committed
feat(sdk): make config optional for the global postprocessor
1 parent b4eafae commit 99c96ba

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

typegraph/core/src/typegraph.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,11 @@ pub fn finalize(res_config: Option<ArtifactResolutionConfig>) -> Result<String>
215215
deps: Default::default(),
216216
};
217217

218-
if let Some(config) = res_config {
219-
// Typically happens when the cli is used
220-
if let Some(prefix) = config.prefix.clone() {
221-
tg.meta.prefix = Some(prefix);
222-
}
223-
224-
TypegraphPostProcessor::new(config).postprocess(&mut tg)?;
225-
}
218+
let config = res_config.map(|config| {
219+
tg.meta.prefix = config.prefix.clone();
220+
config
221+
});
222+
TypegraphPostProcessor::new(config).postprocess(&mut tg)?;
226223

227224
Store::restore(ctx.saved_store_state.unwrap());
228225

typegraph/core/src/utils/postprocess/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,28 @@ pub trait PostProcessor {
2424

2525
/// Compose all postprocessors
2626
pub struct TypegraphPostProcessor {
27-
config: ArtifactResolutionConfig,
27+
config: Option<ArtifactResolutionConfig>,
2828
}
2929

3030
impl TypegraphPostProcessor {
31-
pub fn new(config: ArtifactResolutionConfig) -> Self {
31+
pub fn new(config: Option<ArtifactResolutionConfig>) -> Self {
3232
Self { config }
3333
}
3434
}
3535

3636
impl PostProcessor for TypegraphPostProcessor {
3737
fn postprocess(self, tg: &mut Typegraph) -> Result<(), TgError> {
38-
Store::set_deploy_cwd(self.config.dir);
39-
PrismaProcessor::new(self.config.prisma_migration).postprocess(tg)?;
38+
if let Some(config) = self.config {
39+
Store::set_deploy_cwd(config.dir); // fs_host::cwd() will now use this value
40+
PrismaProcessor::new(config.prisma_migration).postprocess(tg)?;
41+
}
42+
43+
// Artifact resolution depends on the default cwd() (parent process)
44+
// unless overwritten by `dir` through Store::set_deploy_cwd(..) (cli or custom dir with tgDeploy)
4045
DenoProcessor.postprocess(tg)?;
4146
PythonProcessor.postprocess(tg)?;
4247
WasmedgeProcessor.postprocess(tg)?;
48+
4349
ValidationProcessor.postprocess(tg)?;
4450
Ok(())
4551
}

0 commit comments

Comments
 (0)