Socket
Socket
Sign inDemoInstall

closest-root

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

closest-root


Version published
Maintainers
1
Created

Readme

Source

closest-root

This npm module allows for the user to locate the closest npm root directory from a specified path.

Notice

It is assumed that there is a 'package.json' file located at the root of the application (or module). This means that we cannot have files called 'package.json' in the traversal path, as that will then be viewed as a correct root directory.

What we do know for sure, however, is that according to an issue for npm on GitHub, the name of the 'package.json' file will most certainly not change anytime soon. As such, it is imperative that any other files that need to be called 'package.json' are moved to another directory, where it does not interfere with this module

Installation

$ npm install closest-root

Usage

let rootDirectory = require('closest-root')(__dirname)

/* This will output the closest root directory from the current file, as 
 * '__dirname' returns the name of the current directory we are inside.
 */
console.log(rootDirectory)

License

This module, and the code therein, is licensed under ISC.

Keywords

FAQs

Last updated on 05 Mar 2018

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc