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).

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

Supply an options object as the second parameter with a field ignore that contains a list of the directories that you want to ignore when looking for candidate app roots.

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

var options = {
  ignore: ['bower_components', 'vendor', 'node_modules', '.git']
};

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

Keywords

FAQs

Package last updated on 21 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