1.0.0 • Published 6 years ago

deepest-common-folder v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

deepest-common-folder

Node module that finds the deepest common folder from an array of given paths

MIT License Version 1.0.0 Travis CI

About

This module takes in an array of path strings and determines the deepest common folder. This means that it finds the deepest possible parent folder that is shared by all paths in the passed array.

Install

npm i -S deepest-common-folder

Testing

npm run test

Usage

Below is an example of how this module can be used. Please note that if an empty array is passed, then / will be returned. Also if relative paths are used, they will be resolved based on the CWD. An absolute path with a trailing / will always be returned. If a non-array is passed, then an exception is thrown.

const dcf = require ("deepest-common-folder")

let paths = [
	"/foo/bar",
	"/foo/bar/baz",
	"/foo/baz",
	"/foo/baz/bar"
]

let folder = dcf ( paths )