Skip to content

Commit e03f69e

Browse files
committed
cargo-add:remove old tricks, use a more robust invokation
1 parent 84bdf3e commit e03f69e

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

crates/irust/src/irust/parser.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,29 @@ impl IRust {
183183
// Note this might be a bit too aggressive (an argument might be canonicalized, that the user didn't not intend for it to be considered as a path)
184184
// But the usefulness of this trick, outways this possible edge case
185185
// canonicalize is problamatic on windows -> need to handle extended path
186-
#[cfg(unix)]
187-
for p in dep.iter_mut() {
188-
let path = std::path::Path::new(p);
189-
if path.exists() {
190-
if let Ok(full_path) = path.canonicalize() {
191-
if let Some(full_path) = full_path.to_str() {
192-
*p = full_path.to_string();
193-
}
194-
}
195-
}
196-
}
186+
// #[cfg(unix)]
187+
// for p in dep.iter_mut() {
188+
// let path = std::path::Path::new(p);
189+
// if path.exists() {
190+
// if let Ok(full_path) = path.canonicalize() {
191+
// if let Some(full_path) = full_path.to_str() {
192+
// *p = full_path.to_string();
193+
// }
194+
// }
195+
// }
196+
// }
197197
// But still the most common case is `:add .` so we can special case that
198-
#[cfg(windows)]
199-
for p in dep.iter_mut() {
200-
if p == "." {
201-
*p = self
202-
.global_variables
203-
.get_cwd()
204-
.to_str()
205-
.ok_or("Error parsing path to dependecy")?
206-
.to_string();
207-
}
208-
}
198+
// #[cfg(windows)]
199+
// for p in dep.iter_mut() {
200+
// if p == "." {
201+
// *p = self
202+
// .global_variables
203+
// .get_cwd()
204+
// .to_str()
205+
// .ok_or("Error parsing path to dependecy")?
206+
// .to_string();
207+
// }
208+
// }
209209

210210
self.wait_add(self.repl.add_dep(&dep)?, "Add")?;
211211
self.wait_add(self.repl.build()?, "Build")?;

crates/irust_repl/src/cargo_cmds.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ edition = \"2021\""
178178

179179
pub fn cargo_add(&self, dep: &[String]) -> io::Result<std::process::Child> {
180180
Command::new("cargo")
181-
.current_dir(&self.paths.irust_dir)
182181
.arg("add")
183182
.args(dep)
183+
.args(&[
184+
"--manifest-path",
185+
&self.paths.cargo_toml_file.display().to_string(),
186+
])
184187
.stdout(std::process::Stdio::null())
185188
.stderr(std::process::Stdio::piped())
186189
.spawn()

0 commit comments

Comments
 (0)