piuccio.precinct
v3.2.0
Published
Unleash the detectives
Downloads
3
Maintainers
Readme
Precinct
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 tofalse
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