Skip to content

Commit

Permalink
chore: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Oct 16, 2024
1 parent d952294 commit dffd25e
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions crates/binding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(clippy::all)]

use std::cmp::Ordering;
use std::sync::{Arc, Once};

use js_hook::{JsHooks, TsFnHooks};
Expand Down Expand Up @@ -194,39 +193,10 @@ pub fn build(env: Env, build_params: BuildParams) -> napi::Result<JsObject> {
}

// sort with enforce: pre / post
plugins.sort_by(|a, b| {
let a_enforce = a.enforce();
let b_enforce = b.enforce();
match (a_enforce, b_enforce) {
(Some(a_enforce), Some(b_enforce)) => {
if a_enforce == "pre" || b_enforce == "post" {
Ordering::Less
} else if a_enforce == "post" || b_enforce == "pre" {
Ordering::Greater
} else {
Ordering::Equal
}
}
(Some(a_enforce), None) => {
if a_enforce == "pre" {
Ordering::Less
} else if a_enforce == "post" {
Ordering::Greater
} else {
Ordering::Equal
}
}
(None, Some(b_enforce)) => {
if b_enforce == "post" {
Ordering::Greater
} else if b_enforce == "pre" {
Ordering::Less
} else {
Ordering::Equal
}
}
(None, None) => Ordering::Equal,
}
plugins.sort_by_key(|plugin| match plugin.enforce().as_deref() {
Some("pre") => 0,
Some("post") => 2,
_ => 1,
});

let root = std::path::PathBuf::from(&build_params.root);
Expand Down

0 comments on commit dffd25e

Please sign in to comment.