Skip to content

Commit

Permalink
fzf-make 0.45.0
Browse files Browse the repository at this point in the history
fzf-make: try out some build patch

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
BrewTestBot authored and chenrui333 committed Dec 11, 2024
1 parent cc2b49a commit 6087b1e
Showing 1 changed file with 73 additions and 2 deletions.
75 changes: 73 additions & 2 deletions Formula/f/fzf-make.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class FzfMake < Formula
desc "Fuzzy finder with preview window for make, pnpm, & yarn"
homepage "https://github.com/kyu08/fzf-make"
url "https://github.com/kyu08/fzf-make/archive/refs/tags/v0.44.0.tar.gz"
sha256 "bd75b11577e7b702474b462886e9645ebda05269894e0fb09d5219ccde9b6842"
url "https://github.com/kyu08/fzf-make/archive/refs/tags/v0.45.0.tar.gz"
sha256 "275fafd5ed2d9e7f9d08af44f61259b7d57633c6039c3ac8a407e005530ed2c6"
license "MIT"
head "https://github.com/kyu08/fzf-make.git", branch: "main"

Expand All @@ -18,6 +18,8 @@ class FzfMake < Formula
depends_on "rust" => :build
depends_on "bat"

patch :DATA

def install
system "cargo", "install", *std_cargo_args
end
Expand All @@ -43,3 +45,72 @@ def install
end
end
end

__END__
diff --git a/src/model/js_package_manager/yarn.rs b/src/model/js_package_manager/yarn.rs
index 4ce793b..7482458 100644
--- a/src/model/js_package_manager/yarn.rs
+++ b/src/model/js_package_manager/yarn.rs
@@ -171,30 +171,44 @@ impl Yarn {
.collect()
}

- // yarn v1 support `yarn workspaces info --json` instead of `yarn workspaces list --json`.
- // We need to handle them separately, because their output format is different.
+ /// Determines the installed Yarn version, if available.
+ /// yarn v1 support `yarn workspaces info --json` instead of `yarn workspaces list --json`.
+ /// We need to handle them separately, because their output format is different.
+ ///
+ /// # Returns
+ /// - `Some(YarnVersion::V1)` if Yarn v1 is detected.
+ /// - `Some(YarnVersion::V2OrLater)` if Yarn v2 or later is detected.
+ /// - `None` if Yarn is not installed or cannot be executed.
fn get_yarn_version() -> Option<YarnVersion> {
let output = process::Command::new("yarn")
.arg("--version")
- .output()
- .expect("failed to run yarn --version");
+ .output();
+
+ match output {
+ Ok(output) => {
+ if !output.status.success() {
+ eprintln!(
+ "Warning: Failed to run 'yarn --version'. Exit code: {}",
+ output.status.code().unwrap_or(-1)
+ );
+ return None;
+ }

- if let Some(s) = output.status.code() {
- // yarn is not installed
- if s != 0 {
- return None;
- }
- }
+ let version = String::from_utf8_lossy(&output.stdout).trim().to_string();
+ /* Example output:
+ "1.22.22\n"
+ */

- let output = String::from_utf8(output.stdout).expect("failed to convert to string");
- /* output is like:
- "1.22.22\n"
- */
-
- if output.trim().starts_with("1.") {
- Some(YarnVersion::V1)
- } else {
- Some(YarnVersion::V2OrLater)
+ if version.starts_with("1.") {
+ Some(YarnVersion::V1)
+ } else {
+ Some(YarnVersion::V2OrLater)
+ }
+ }
+ Err(err) => {
+ eprintln!("Warning: 'yarn' is not installed or not found in PATH. Error: {}", err);
+ None
+ }
}
}

0 comments on commit 6087b1e

Please sign in to comment.