Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

  • 1.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-11.11%
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).

npm install app-root

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

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

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

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

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 28 Mar 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