https://github.com/matiascarabella/common-ancestor-finder
A command-line tool for navigating the file system and finding the common parent directory of two given file paths. It helps in efficiently determining the lowest common ancestor in a directory structure.
https://github.com/matiascarabella/common-ancestor-finder
Last synced: about 14 hours ago
JSON representation
A command-line tool for navigating the file system and finding the common parent directory of two given file paths. It helps in efficiently determining the lowest common ancestor in a directory structure.
- Host: GitHub
- URL: https://github.com/matiascarabella/common-ancestor-finder
- Owner: MatiasCarabella
- License: mit
- Created: 2024-06-10T21:23:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-10T21:40:09.000Z (over 1 year ago)
- Last Synced: 2024-12-28T00:23:49.810Z (10 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CommonAncestorFinder
CommonAncestorFinder is a command-line tool designed to navigate the file system and find the common parent directory of two given file paths. This tool is useful for operations that require determining the lowest common ancestor in a directory structure.
## Features
- Navigate the file system hierarchy
- Find the common parent directory for two given file paths
- Simple and intuitive interface
## Usage
1. **Clone the repository:**
```sh
git clone https://github.com/MatiasCarabella/CommonAncestorFinder.git
cd CommonAncestorFinder
```
2. **Run the tool:**
```sh
node CommonAncestorFinder.js
```
3. **Example:**
```javascript
const root = new File('root');
const [a, b, c, d] = ['a', 'b', 'c', 'd'].map(char => new File(char));
root.addChild(a);
root.addChild(b);
a.addChild(c);
a.addChild(d);
console.log(`The common parent of a and b is: ${findParent(root, a, b).name}`); // -> root
console.log(`The common parent of c and d is: ${findParent(root, c, d).name}`); // -> a
```
4. **Expected Output:**
```sh
The common parent of a and b is: root
The common parent of c and d is: a
```
## Installation
To use CommonAncestorFinder, ensure you have [Node.js](https://nodejs.org/) installed.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.