Skip to content

Commit 0c3faca

Browse files
authored
Remove setting env vars for WIT parsing (#1075)
1 parent aced4ea commit 0c3faca

1 file changed

Lines changed: 2 additions & 22 deletions

File tree

crates/codegen/src/exports.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{anyhow, Result};
22
use convert_case::{Case, Casing};
3-
use std::{env, path::Path};
3+
use std::path::Path;
44

55
use crate::js::JS;
66
use crate::wit;
@@ -15,7 +15,7 @@ pub(crate) struct Export {
1515

1616
pub(crate) fn process_exports(js: &JS, wit: &Path, wit_world: &str) -> Result<Vec<Export>> {
1717
let js_exports = js.exports()?;
18-
parse_wit_exports(wit, wit_world)?
18+
wit::parse_exports(wit, wit_world)?
1919
.into_iter()
2020
.map(|wit_export| {
2121
let export = wit_export.from_case(Case::Kebab).to_case(Case::Camel);
@@ -30,23 +30,3 @@ pub(crate) fn process_exports(js: &JS, wit: &Path, wit_world: &str) -> Result<Ve
3030
})
3131
.collect::<Result<Vec<Export>>>()
3232
}
33-
34-
fn parse_wit_exports(wit: &Path, wit_world: &str) -> Result<Vec<String>> {
35-
// Configure wit-parser to not require semicolons but only if the relevant
36-
// environment variable is not already set.
37-
const SEMICOLONS_OPTIONAL_ENV_VAR: &str = "WIT_REQUIRE_SEMICOLONS";
38-
let semicolons_env_var_already_set = env::var(SEMICOLONS_OPTIONAL_ENV_VAR).is_ok();
39-
if !semicolons_env_var_already_set {
40-
env::set_var(SEMICOLONS_OPTIONAL_ENV_VAR, "0");
41-
}
42-
43-
let exports = wit::parse_exports(wit, wit_world);
44-
45-
// If we set the environment variable to not require semicolons, remove
46-
// that environment variable now that we no longer need it set.
47-
if !semicolons_env_var_already_set {
48-
env::remove_var(SEMICOLONS_OPTIONAL_ENV_VAR);
49-
}
50-
51-
exports
52-
}

0 commit comments

Comments
 (0)