You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

commondir

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commondir

compute the closest common parent for file paths


Version published
Weekly downloads
20M
increased by0.87%
Maintainers
1
Install size
5.51 kB
Created
Weekly downloads
 

Package description

What is commondir?

The commondir npm package is a simple utility that helps you find the common parent directory among an array of file paths. This can be particularly useful in file system operations where you need to determine the shared base directory for a group of files.

What are commondir's main functionalities?

Finding common directory

This feature allows you to find the common parent directory from an array of file paths. In the provided code, the common directory for '/usr/lib/node_modules' and '/usr/lib/node' is calculated, which results in '/usr/lib'.

const commondir = require('commondir');
const paths = ['/usr/lib/node_modules', '/usr/lib/node'];
const commonPath = commondir(paths);
console.log(commonPath); // Outputs: '/usr/lib'

Other packages similar to commondir

Readme

Source

commondir

compute the closest common parent directory among an array of directories

example

var commondir = require('commondir');
var dir = commondir(process.argv.slice(2))
console.log(dir);

output:

$ node dir.js /x/y/z /x/y /x/y/w/q
/x/y
$ node ../baz ../../foo/quux ./bizzy
/foo

methods

var commondir = require('commondir');

commondir(absolutePaths)

Compute the closest common parent directory for an array absolutePaths.

commondir(basedir, relativePaths)

Compute the closest common parent directory for an array relativePaths which will be resolved for each dir in relativePaths according to: path.resolve(basedir, dir).

install

With npm do:

npm install commondir

license

MIT

Keywords

FAQs

Package last updated on 14 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc