refactor: Removed leftover javascript function support; will not implement
This commit is contained in:
+7
-9
@@ -41,7 +41,6 @@ enum BinaryType {
|
|||||||
enum Language {
|
enum Language {
|
||||||
Bash,
|
Bash,
|
||||||
Python,
|
Python,
|
||||||
Javascript,
|
|
||||||
Unsupported,
|
Unsupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ impl From<&String> for Language {
|
|||||||
match s.to_lowercase().as_str() {
|
match s.to_lowercase().as_str() {
|
||||||
"sh" => Language::Bash,
|
"sh" => Language::Bash,
|
||||||
"py" => Language::Python,
|
"py" => Language::Python,
|
||||||
"js" => Language::Javascript,
|
|
||||||
_ => Language::Unsupported,
|
_ => Language::Unsupported,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +60,6 @@ impl Language {
|
|||||||
match self {
|
match self {
|
||||||
Language::Bash => "bash",
|
Language::Bash => "bash",
|
||||||
Language::Python => "python",
|
Language::Python => "python",
|
||||||
Language::Javascript => "node",
|
|
||||||
Language::Unsupported => "sh",
|
Language::Unsupported => "sh",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,7 +68,6 @@ impl Language {
|
|||||||
match self {
|
match self {
|
||||||
Language::Bash => "sh",
|
Language::Bash => "sh",
|
||||||
Language::Python => "py",
|
Language::Python => "py",
|
||||||
Language::Javascript => "js",
|
|
||||||
_ => "sh",
|
_ => "sh",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,8 +120,6 @@ pub struct Functions {
|
|||||||
|
|
||||||
impl Functions {
|
impl Functions {
|
||||||
fn install_global_tools() -> Result<()> {
|
fn install_global_tools() -> Result<()> {
|
||||||
ensure_parent_exists(&Config::global_tools_file())?;
|
|
||||||
|
|
||||||
info!("Installing global built-in functions in {}", Config::functions_dir().display());
|
info!("Installing global built-in functions in {}", Config::functions_dir().display());
|
||||||
|
|
||||||
for file in FunctionAssets::iter() {
|
for file in FunctionAssets::iter() {
|
||||||
@@ -367,7 +361,6 @@ impl Functions {
|
|||||||
Language::Unsupported => {
|
Language::Unsupported => {
|
||||||
bail!("Unsupported tool file extension: {}", language.as_ref())
|
bail!("Unsupported tool file extension: {}", language.as_ref())
|
||||||
}
|
}
|
||||||
_ => bail!("Unsupported tool language: {}", language.as_ref()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||||
@@ -533,8 +526,13 @@ impl Functions {
|
|||||||
language.to_cmd()
|
language.to_cmd()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Language::Javascript => runtime::which(language.to_cmd())
|
Language::Python => {
|
||||||
.ok_or_else(|| anyhow!("Unable to find {} in PATH", language.to_cmd()))?,
|
let executable_path = which::which("python")
|
||||||
|
.or_else(|_| which::which("python3"))
|
||||||
|
.map_err(|_| anyhow!("Python executable not found in PATH"))?;
|
||||||
|
let canonicalized_path = fs::canonicalize(&executable_path)?;
|
||||||
|
canonicalized_path.to_string_lossy().into_owned()
|
||||||
|
}
|
||||||
_ => bail!("Unsupported language: {}", language.as_ref()),
|
_ => bail!("Unsupported language: {}", language.as_ref()),
|
||||||
};
|
};
|
||||||
let bin_dir = binary_file
|
let bin_dir = binary_file
|
||||||
|
|||||||
Reference in New Issue
Block a user