Skip to content

piuccio/node-precinct

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Precinct npm npm

Unleash the detectives

npm install precinct

Uses the appropriate detective to find the dependencies of a file or its AST.

Supports:

  • JavaScript modules: AMD, CommonJS, and ES6.
  • Sass dependencies via detective-sass.
  • Stylus

Usage

var precinct = require('precinct');

var content = fs.readFileSync('myFile.js', 'utf8');

// Pass in a file's content or an AST
var deps = precinct(content);

Finding non-JavaScript (ex: Sass and Stylus) dependencies:

var content = fs.readFileSync('styles.scss', 'utf8');

var deps = precinct(content, 'sass');
var deps2 = precinct(content, 'stylus');

Or, if you just want to pass in a filepath and get the dependencies:

var paperwork = require('precinct').paperwork;

var deps = paperwork('myFile.js');
var deps2 = paperwork('styles.scss');
precinct.paperwork(filename, options)
  • includeCore: (default: true) set to false to exclude core Node dependencies from the list of dependencies.

You can also pass options to individual detectives, for example

  • amd.skipLazyLoaded tells the AMD detective to omit inner requires

License

MIT

About

Unleash the detectives

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.6%
  • CSS 1.4%