| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A TypeScript library that automatically detects project root directories by analyzing file patterns and project indicators.
This library scans file system paths to find the root directory of software projects. It looks for common project files like package.json, tsconfig.json, go.mod, and many others to determine where a project actually begins.
npm install @neabyte/project-rootimport { findProjectRoot } from '@neabyte/project-root'
// Find the project root from a file path
const projectRoot = findProjectRoot('/path/to/some/file.ts')
console.log(projectRoot) // '/path/to/project/root'import { findProjectDeep } from '@neabyte/project-root'
// Find all projects in a directory tree
const projects = findProjectDeep('/path/to/directory', 5, false)
console.log(projects)
// [
// { path: '/path/to/directory/project1', score: 45, depth: 0, relativePath: '.' },
// { path: '/path/to/directory/project2', score: 32, depth: 1, relativePath: 'subfolder' }
// ]Searches upward from the given path to find the project root.
Parameters:
Returns:
Recursively scans a directory tree to find all project roots.
Parameters:
Returns:
The library detects projects based on common configuration files and patterns:
The library uses a scoring system to determine project roots:
Each indicator has a different score weight. For example:
The library automatically excludes common build and cache directories:
The library is written in TypeScript and provides full type definitions:
interface ProjectDiscovery {
path: string
score: number
depth: number
relativePath: string
}
interface BestMatch {
path: string
score: number
}
interface Indicator extends BestMatch {
name: string
}This project is licensed under the MIT license. See the LICENSE file for more info.
| Back | FazBrowse Home | New Git URL |