|
1 | 1 | extern crate zip;
|
2 |
| -use std::fs::File; |
3 |
| -use std::str::FromStr; |
4 | 2 | use std::io::Result;
|
5 | 3 | use std::env;
|
6 |
| - |
7 |
| -use std::io::BufReader; |
8 |
| -use std::path::{Path, PathBuf}; |
9 |
| -use std::process::{Command, Stdio}; |
| 4 | +use std::path::PathBuf; |
| 5 | +use std::process::Command; |
10 | 6 |
|
11 | 7 | use std::fs;
|
12 | 8 | use std::io;
|
13 | 9 |
|
14 | 10 | #[cfg(target_os = "linux")]
|
15 |
| -const KALEIDO_URL: &'static str = "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_linux-0.0.1rc9.zip"; |
| 11 | +const KALEIDO_URL: &str = "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_linux-0.0.1rc9.zip"; |
16 | 12 | #[cfg(target_os = "windows")]
|
17 |
| -const KALEIDO_URL: &'static str= "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_win-0.0.1rc9.zip"; |
| 13 | +const KALEIDO_URL: &str= "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_win-0.0.1rc9.zip"; |
18 | 14 | #[cfg(target_os = "macos")]
|
19 |
| -const KALEIDO_URL: &'static str = "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_mac-0.0.1rc9.zip"; |
| 15 | +const KALEIDO_URL: &str = "https://github.com/plotly/Kaleido/releases/download/v0.0.1rc9/kaleido_mac-0.0.1rc9.zip"; |
20 | 16 |
|
21 | 17 |
|
22 | 18 | fn extract_zip(p: &PathBuf, zip_file: &PathBuf) -> Result<()> {
|
@@ -70,28 +66,28 @@ fn extract_zip(p: &PathBuf, zip_file: &PathBuf) -> Result<()> {
|
70 | 66 | }
|
71 | 67 | }
|
72 | 68 |
|
73 |
| - fs::remove_file(zip_file); |
| 69 | + fs::remove_file(zip_file)?; |
74 | 70 | Ok(())
|
75 | 71 | }
|
76 | 72 |
|
77 | 73 |
|
78 | 74 | fn main() -> Result<()> {
|
79 |
| - let mut p = PathBuf::from(env::var("OUT_DIR").unwrap()); |
| 75 | + let p = PathBuf::from(env::var("OUT_DIR").unwrap()); |
80 | 76 | let mut dst = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
81 | 77 | dst = dst.parent().unwrap().to_path_buf();
|
82 | 78 | dst = dst.join("plotly_kaleido");
|
83 | 79 |
|
84 | 80 |
|
85 |
| - let mut kaleido_zip_file = p.join("kaleido.zip"); |
| 81 | + let kaleido_zip_file = p.join("kaleido.zip"); |
86 | 82 |
|
87 | 83 | let mut cmd = Command::new("cargo")
|
88 | 84 | .args(&["install", "ruget"]).spawn().unwrap();
|
89 |
| - cmd.wait(); |
| 85 | + cmd.wait()?; |
90 | 86 |
|
91 | 87 | let mut cmd = Command::new("ruget")
|
92 | 88 | .args(&[KALEIDO_URL, "-o", kaleido_zip_file.as_path().to_str().unwrap()])
|
93 | 89 | .spawn().unwrap();
|
94 |
| - cmd.wait(); |
| 90 | + cmd.wait()?; |
95 | 91 |
|
96 | 92 | extract_zip(&dst, &kaleido_zip_file)?;
|
97 | 93 | Ok(())
|
|
0 commit comments