fix: 🐛 correctly enable fields with features

This commit is contained in:
daimond113 2024-03-24 18:48:26 +01:00
parent e999f65ce9
commit ba6c218847
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 22 additions and 15 deletions

View file

@ -3,7 +3,6 @@ use chrono::Utc;
use std::{ use std::{
collections::{BTreeMap, HashMap}, collections::{BTreeMap, HashMap},
fs::{create_dir_all, read, remove_dir_all, write, File}, fs::{create_dir_all, read, remove_dir_all, write, File},
process::Command as SysCommand,
str::FromStr, str::FromStr,
time::Duration, time::Duration,
}; };
@ -115,17 +114,20 @@ pub fn root_command(cmd: Command) -> anyhow::Result<()> {
"Downloading packages".to_string(), "Downloading packages".to_string(),
)?; )?;
#[allow(unused_variables)]
project.convert_manifests(&resolved_versions_map, |path| { project.convert_manifests(&resolved_versions_map, |path| {
cfg_if! {
if #[cfg(feature = "wally")] {
if let Some(sourcemap_generator) = &manifest.sourcemap_generator { if let Some(sourcemap_generator) = &manifest.sourcemap_generator {
cfg_if! { cfg_if! {
if #[cfg(target_os = "windows")] { if #[cfg(target_os = "windows")] {
SysCommand::new("pwsh") std::process::Command::new("pwsh")
.args(["-C", &sourcemap_generator]) .args(["-C", &sourcemap_generator])
.current_dir(path) .current_dir(path)
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
} else { } else {
SysCommand::new("sh") std::process::Command::new("sh")
.args(["-c", &sourcemap_generator]) .args(["-c", &sourcemap_generator])
.current_dir(path) .current_dir(path)
.output() .output()
@ -133,6 +135,8 @@ pub fn root_command(cmd: Command) -> anyhow::Result<()> {
} }
} }
} }
}
}
})?; })?;
let project = Lazy::force_mut(&mut project); let project = Lazy::force_mut(&mut project);
@ -414,6 +418,7 @@ pub fn root_command(cmd: Command) -> anyhow::Result<()> {
DEFAULT_INDEX_NAME.to_string(), DEFAULT_INDEX_NAME.to_string(),
DEFAULT_INDEX_URL.to_string(), DEFAULT_INDEX_URL.to_string(),
)]), )]),
#[cfg(feature = "wally")]
sourcemap_generator: None, sourcemap_generator: None,
dependencies: Default::default(), dependencies: Default::default(),

View file

@ -41,6 +41,7 @@ fn test_resolves_package() {
private: true, private: true,
realm: None, realm: None,
indices: Default::default(), indices: Default::default(),
#[cfg(feature = "wally")]
sourcemap_generator: None, sourcemap_generator: None,
dependencies: vec![], dependencies: vec![],
@ -80,6 +81,7 @@ fn test_resolves_package() {
private: true, private: true,
realm: None, realm: None,
indices: Default::default(), indices: Default::default(),
#[cfg(feature = "wally")]
sourcemap_generator: None, sourcemap_generator: None,
dependencies: vec![specifier.clone()], dependencies: vec![specifier.clone()],