Try to add Sass support
This commit is contained in:
1 parent
2c9f5f1957
commit
5d013ecf82
2 files changed
+35
-2
No files matched your search
@@ -42,4 +42,7 @@ script = []
|
||||
|
||||
# use binaryen.wasm-opt for output Wasm file
|
||||
# binaryen just will trigger in `web` platform
|
||||
binaryen = { wasm_opt = true }
|
||||
binaryen = { wasm_opt = true }
|
||||
|
||||
# use sass auto will auto check sass file and build it.
|
||||
sass = { auto = true }
|
||||
+31
-1
@@ -13,10 +13,11 @@ use tokio::io::AsyncWriteExt;
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Tool {
|
||||
Binaryen,
|
||||
Sass,
|
||||
}
|
||||
|
||||
pub fn tool_list() -> Vec<&'static str> {
|
||||
vec!["binaryen"]
|
||||
vec!["binaryen", "sass"]
|
||||
}
|
||||
|
||||
pub fn app_path() -> PathBuf {
|
||||
@@ -60,6 +61,7 @@ impl Tool {
|
||||
pub fn name(&self) -> &str {
|
||||
match self {
|
||||
Self::Binaryen => "binaryen",
|
||||
Self::Sass => "sass",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +69,7 @@ impl Tool {
|
||||
pub fn bin_path(&self) -> &str {
|
||||
match self {
|
||||
Self::Binaryen => "bin",
|
||||
Self::Sass => ".",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +87,17 @@ impl Tool {
|
||||
panic!("unsupported platformm");
|
||||
}
|
||||
}
|
||||
Self::Sass => {
|
||||
if cfg!(target_os = "windows") {
|
||||
"windows"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"macos"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"linux"
|
||||
} else {
|
||||
panic!("unsupported platformm");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +110,12 @@ impl Tool {
|
||||
target = self.target_platform()
|
||||
)
|
||||
}
|
||||
Self::Sass => {
|
||||
format!(
|
||||
"https://github.com/sass/dart-sass/releases/download/1.51.0/dart-sass-1.51.0-{target}-x64.tar.gz",
|
||||
target = self.target_platform()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +123,13 @@ impl Tool {
|
||||
pub fn extension(&self) -> &str {
|
||||
match self {
|
||||
Self::Binaryen => "tar.gz",
|
||||
Self::Sass => {
|
||||
if cfg!(target_os = "windows") {
|
||||
"zip"
|
||||
} else {
|
||||
"tar.ge"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +196,9 @@ impl Tool {
|
||||
command.to_string()
|
||||
}
|
||||
}
|
||||
Tool::Sass => {
|
||||
command.to_string()
|
||||
}
|
||||
};
|
||||
|
||||
if !bin_path.join(&command_file).is_file() {
|
||||
|
||||
Reference in new issue
Block a user