Socket
Socket
Sign inDemoInstall

app-root

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-root

Find the entry-point/root file of any CommonJS or AMD JavaScript application


Version published
Weekly downloads
28
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

Returns a list of candidate root files for CommonJS or AMD JavaScript applications within a directory.

A root/entry-point file is one that has dependencies but is not depended on (i.e., no other file requires it).

This is useful for automatically deducing the entry point for r.js or browserify configurations.

npm install app-root

Usage

var getAppRoot = require('app-root');

// Find the application roots within the js folder
getAppRoot('./js', function (roots) {
  ...
})

Or via a shell command

approot directory

  • Where directory is the directory containing roots you'd like to identify

Ignoring particular subdirectories or files

Supply an options object as the second parameter.

Supported options:

  • ignoreDirectories: list of directory names (strings or regex) to ignore
  • ignoreFiles: list of file names (strings or regex) to ignore

These lists will be managed by an exclusion-manager.

Directory or filenames that match elements of the above lists will be ignored when looking for candidate app roots.

Otherwise, you'd end up with junk roots for 3rd party libraries/dependencies.

var options = {
  ignoreDirectories: [/.+_components/, 'vendor', 'node_modules', '.git'],
  ignoreFiles: ['Gruntfile.js']
};

getAppRoot('./js', options, function (roots) {
  ...
})

Keywords

FAQs

Package last updated on 06 Jun 2014

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc