3.0.0 • Published 6 years ago

app-root v3.0.0

Weekly downloads
36
License
MIT
Repository
github
Last release
6 years ago

app-root npm npm

Returns a list of application entry points for front-end applications (JS and Sass).

npm install app-root

An entry point (i.e., root) is a file that no other file requires/imports.

Works with AMD, CommonJS, ES6, and SASS apps.

This library is particularly useful for automatically deducing the entry point for r.js or browserify configurations as done in YA.

A directory may have many roots. This is true if you have multiple apps within a single directory or if your app uses a multi-bundle architecture (where each page on your site has its own JS app).

Usage

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

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

With configurable options:

getAppRoot({
  directory: './js',
  success: function (roots) {
    ...
  },

  ignoreDirectories: [/.+_components/, 'vendor', 'node_modules', '.git'],
  ignoreFiles: ['Gruntfile.js'],
  includeNoDependencyModules: true,
  config: 'path/to/my/requirejs/config.js'
});

Options

  • ignoreDirectories: list of directory names (strings or regex) to ignore
  • ignoreFiles: list of file names (strings or regex) to ignore
  • includeNoDependencyModules: (default false) Whether or not to include, as potential roots, modules that have no dependencies
  • config: path to your module loader configuration (for resolving aliased module paths)

Or via a shell command

approot directory

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

6 years ago

2.0.3

8 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.7

10 years ago

1.2.6

10 years ago

1.2.5

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.0

10 years ago