Skip to content

Commit

Permalink
Merge pull request #758 from charlespierce/reorder_helper_functions
Browse files Browse the repository at this point in the history
[Tiny] Move helper functions to bottom of Project module
  • Loading branch information
charlespierce authored Jun 5, 2020
2 parents d4c2237 + 2def04b commit 2876e19
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions crates/volta-core/src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ pub struct Project {
project_root: PathBuf,
}

fn is_node_root(dir: &Path) -> bool {
dir.join("package.json").is_file()
}

fn is_node_modules(dir: &Path) -> bool {
dir.file_name() == Some(OsStr::new("node_modules"))
}

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

fn is_project_root(dir: &Path) -> bool {
is_node_root(dir) && !is_dependency(dir)
}

impl Project {
/// Returns the Node project containing the current working directory,
/// if any.
Expand Down Expand Up @@ -193,6 +177,22 @@ impl Project {
}
}

fn is_node_root(dir: &Path) -> bool {
dir.join("package.json").is_file()
}

fn is_node_modules(dir: &Path) -> bool {
dir.file_name() == Some(OsStr::new("node_modules"))
}

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

fn is_project_root(dir: &Path) -> bool {
is_node_root(dir) && !is_dependency(dir)
}

// unit tests

#[cfg(test)]
Expand Down

0 comments on commit 2876e19

Please sign in to comment.