File src/backend/fetch.rs changed (mode: 100644) (index 6ee12ad..eb413a0) |
... |
... |
pub fn build(dep: PathBuf, mut command: String) -> Result<String, String> { |
14 |
14 |
None => return Err(String::from("Fetching failed: no appropriate command set.")) |
None => return Err(String::from("Fetching failed: no appropriate command set.")) |
15 |
15 |
} |
} |
16 |
16 |
} |
} |
17 |
|
fetch(dep_name, &dep, command) |
|
|
17 |
|
fetch(dep_name, dep, command) |
18 |
18 |
} |
} |
19 |
19 |
|
|
20 |
20 |
pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> { |
pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> { |
|
... |
... |
pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> { |
26 |
26 |
None => return Err(String::from("Fetching failed: no appropriate command set.")) |
None => return Err(String::from("Fetching failed: no appropriate command set.")) |
27 |
27 |
} |
} |
28 |
28 |
} |
} |
29 |
|
fetch(dep_name, &dep, command) |
|
|
29 |
|
fetch(dep_name, dep, command) |
30 |
30 |
} |
} |
31 |
31 |
|
|
32 |
|
fn fetch(dep_name: String, path: &PathBuf, command: String) -> Result<String, String> { |
|
|
32 |
|
fn fetch(dep_name: String, mut path: PathBuf, command: String) -> Result<String, String> { |
33 |
33 |
let mut args: Vec<&str> = command.split(' ').collect(); |
let mut args: Vec<&str> = command.split(' ').collect(); |
34 |
34 |
let command = args.remove(0); |
let command = args.remove(0); |
|
35 |
|
|
|
36 |
|
if !path.is_dir() { |
|
37 |
|
println!("{} is not a directory. Running command from project root..", path.to_str().unwrap()); |
|
38 |
|
match super::filesystem::get_current_project_root() { |
|
39 |
|
Some(dir) => path = dir, |
|
40 |
|
None => return Err(String::from("No valid fetch directory found!")) |
|
41 |
|
} |
|
42 |
|
} |
|
43 |
|
|
35 |
44 |
let out = Command::new(command) |
let out = Command::new(command) |
36 |
|
.current_dir(path) |
|
|
45 |
|
.current_dir(&path) |
37 |
46 |
.args(args) |
.args(args) |
38 |
47 |
.stdin(Stdio::inherit()) |
.stdin(Stdio::inherit()) |
39 |
48 |
.stdout(Stdio::inherit()) |
.stdout(Stdio::inherit()) |
|
... |
... |
fn fetch(dep_name: String, path: &PathBuf, command: String) -> Result<String, St |
54 |
63 |
|
|
55 |
64 |
let mut error = String::from("Fetching failed: command '"); |
let mut error = String::from("Fetching failed: command '"); |
56 |
65 |
error.push_str(command); |
error.push_str(command); |
|
66 |
|
error.push_str("' in '"); |
|
67 |
|
error.push_str(path.to_str().unwrap()); |
57 |
68 |
error.push_str("' invalid. Details: "); |
error.push_str("' invalid. Details: "); |
58 |
69 |
error.push_str(&e.to_string()); |
error.push_str(&e.to_string()); |
59 |
70 |
error.push_str("\n\nConsider changing the above command in the '"); |
error.push_str("\n\nConsider changing the above command in the '"); |