From be961acaca686641fae1aee49bb20924ddba9f45 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 26 May 2022 17:31:30 -0400 Subject: [PATCH] feat(cli-support): expose more properties on `Output` (#2913) --- crates/cli-support/src/lib.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/cli-support/src/lib.rs b/crates/cli-support/src/lib.rs index d767be55d7e..f902a40b89d 100755 --- a/crates/cli-support/src/lib.rs +++ b/crates/cli-support/src/lib.rs @@ -611,9 +611,38 @@ fn unexported_unused_lld_things(module: &mut Module) { impl Output { pub fn js(&self) -> &str { + &self.gen().js + } + + pub fn ts(&self) -> Option<&str> { + let gen = self.gen(); + if gen.typescript { + Some(&gen.ts) + } else { + None + } + } + + pub fn start(&self) -> Option<&String> { + self.gen().start.as_ref() + } + + pub fn snippets(&self) -> &HashMap> { + &self.gen().snippets + } + + pub fn local_modules(&self) -> &HashMap { + &self.gen().local_modules + } + + pub fn npm_dependencies(&self) -> &HashMap { + &self.gen().npm_dependencies + } + + fn gen(&self) -> &JsGenerated { match &self.generated { Generated::InterfaceTypes => panic!("no js with interface types output"), - Generated::Js(gen) => &gen.js, + Generated::Js(gen) => &gen, } }