feat: commit code

This commit is contained in:
mrxiaozhuox committed 2022-03-12 13:00:07 +08:00
1 parent 91a8ce3169
commit 5fb1b3e20b
4 files changed
+79 -2

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ pub mod config;
pub mod create;
pub mod serve;
pub mod translate;
pub mod tools;
use crate::{
cfg::{ConfigOptsBuild, ConfigOptsServe},
+69
View File
@@ -0,0 +1,69 @@
use std::path::PathBuf;
pub enum Tool {
WasmOpt,
}
pub fn app_path() {
let data_local = dirs::data_local_dir().unwrap();
}
impl Tool {
pub fn name(&self) -> &str {
match self {
Self::WasmOpt => "wasm-opt",
}
}
pub fn bin_path(&self) -> &str {
if cfg!(target_os = "windows") {
match self {
Self::WasmOpt => "bin/wasm-opt.exe",
}
} else {
match self {
Self::WasmOpt => "bin/wasm-opt",
}
}
}
pub fn target_platform(&self) -> &str {
match self {
Self::WasmOpt => {
if cfg!(target_os = "windows") {
"windows"
} else if cfg!(target_os = "macos") {
"macos"
} else if cfg!(target_os = "linux") {
"linux"
} else {
panic!("unsupported platformm");
}
}
}
}
pub fn download_url(&self) -> String {
match self {
Self::WasmOpt => {
format!(
"https://github.com/WebAssembly/binaryen/releases/download/version_105/binaryen-version_105-x86_64-{target}.tar.gz",
target = self.target_platform()
)
}
}
}
pub async fn download_package(&self) {
let download_dir = dirs::download_dir().unwrap();
let download_url = self.download_url();
let resp = reqwest::get(download_url).await.unwrap();
resp.
}
}