From ba6c21884703dcf23e5f3269bebc662e4bdf373f Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Sun, 24 Mar 2024 18:48:26 +0100 Subject: [PATCH] fix: :bug: correctly enable fields with features --- src/cli/root.rs | 35 ++++++++++++++++++++--------------- tests/resolver.rs | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/cli/root.rs b/src/cli/root.rs index 307a152..5c644b8 100644 --- a/src/cli/root.rs +++ b/src/cli/root.rs @@ -3,7 +3,6 @@ use chrono::Utc; use std::{ collections::{BTreeMap, HashMap}, fs::{create_dir_all, read, remove_dir_all, write, File}, - process::Command as SysCommand, str::FromStr, time::Duration, }; @@ -115,21 +114,26 @@ pub fn root_command(cmd: Command) -> anyhow::Result<()> { "Downloading packages".to_string(), )?; + #[allow(unused_variables)] project.convert_manifests(&resolved_versions_map, |path| { - if let Some(sourcemap_generator) = &manifest.sourcemap_generator { - cfg_if! { - if #[cfg(target_os = "windows")] { - SysCommand::new("pwsh") - .args(["-C", &sourcemap_generator]) - .current_dir(path) - .output() - .expect("failed to execute process"); - } else { - SysCommand::new("sh") - .args(["-c", &sourcemap_generator]) - .current_dir(path) - .output() - .expect("failed to execute process"); + cfg_if! { + if #[cfg(feature = "wally")] { + if let Some(sourcemap_generator) = &manifest.sourcemap_generator { + cfg_if! { + if #[cfg(target_os = "windows")] { + std::process::Command::new("pwsh") + .args(["-C", &sourcemap_generator]) + .current_dir(path) + .output() + .expect("failed to execute process"); + } else { + std::process::Command::new("sh") + .args(["-c", &sourcemap_generator]) + .current_dir(path) + .output() + .expect("failed to execute process"); + } + } } } } @@ -414,6 +418,7 @@ pub fn root_command(cmd: Command) -> anyhow::Result<()> { DEFAULT_INDEX_NAME.to_string(), DEFAULT_INDEX_URL.to_string(), )]), + #[cfg(feature = "wally")] sourcemap_generator: None, dependencies: Default::default(), diff --git a/tests/resolver.rs b/tests/resolver.rs index 9d3990d..252eca7 100644 --- a/tests/resolver.rs +++ b/tests/resolver.rs @@ -41,6 +41,7 @@ fn test_resolves_package() { private: true, realm: None, indices: Default::default(), + #[cfg(feature = "wally")] sourcemap_generator: None, dependencies: vec![], @@ -80,6 +81,7 @@ fn test_resolves_package() { private: true, realm: None, indices: Default::default(), + #[cfg(feature = "wally")] sourcemap_generator: None, dependencies: vec![specifier.clone()],