Skip to content

Commit

Permalink
chore: simplify conditional expression
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Dec 25, 2024
1 parent 640c2c1 commit ec03259
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions crates/volta-core/src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Project {
// (project uses Yarn berry if 'yarnrc.yml' exists, uses PnP if '.pnp.js' or '.pnp.cjs' exist)
pub fn needs_yarn_run(&self) -> bool {
self.platform()
.map_or(false, |platform| platform.yarn.is_some())
.is_some_and(|platform| platform.yarn.is_some())
&& self.workspace_roots().any(|x| {
x.join(".yarnrc.yml").exists()
|| x.join(".pnp.cjs").exists()
Expand Down Expand Up @@ -251,11 +251,11 @@ fn is_node_root(dir: &Path) -> bool {
}

fn is_node_modules(dir: &Path) -> bool {
dir.file_name().map_or(false, |tail| tail == "node_modules")
dir.file_name().is_some_and(|tail| tail == "node_modules")
}

fn is_dependency(dir: &Path) -> bool {
dir.parent().map_or(false, is_node_modules)
dir.parent().is_some_and(is_node_modules)
}

fn is_project_root(dir: &Path) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/volta-migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn main() {
// In order to migrate the existing Volta directory while avoiding unconditional changes to the user's system,
// the Homebrew formula runs volta-migrate with `--no-create` flag in the post-install phase.
let no_create = matches!(std::env::args_os().nth(1), Some(flag) if flag == "--no-create");
if no_create && !volta_home().map_or(false, |home| home.root().exists()) {
if no_create && volta_home().map_or(true, |home| !home.root().exists()) {
ExitCode::Success.exit();
}

Expand Down

0 comments on commit ec03259

Please sign in to comment.