0.0.3 • Published 8 years ago

depstat v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

depstat


find all calls to require() or import() from the command line and tells how many times a module has been referenced in the js file(s)

Note:

this module is in very early development, please report any issues to github

searching for es6 modules will only work with jspm as the module loader


Install

$: npm install -g depstat

Usage

from your project's root folder:

$:~/Project$ depstat

depstat will assume the source directory is located at ./src and package.json is located at .:

but this can be changed with options:

$:~/Project$ depstat --path=[path to src files] --dep=[path to package.json]

example 1

with CommonJS loader

~/Project/package.json:

{
  [...]
  "dependencies": {
    "array-flatten": "^2.1.0",
    "colors": "^1.1.2",
    "minimatch": "^3.0.3",
  }
}

~/Project/src/foo.js:

const colors = require('colors');
const flatten = require('array-flatten');
const minimatch = require('minimatch');

then from the command line inside of your project's root folder:

$:~/Project$ depstat

depstat automatically searches through all js files in the ./src directory

the result:

times ref.      dep name                                           format    
___________________________________________________________________________
1               colors                                             CommonJS  
___________________________________________________________________________
1               array-flatten                                      CommonJS  
___________________________________________________________________________
1               minimatch                                          CommonJS  

example 2

with es6 loader - jspm

~/Project/package.json:

"jspm": {
    "directories": {
      "doc": "doc",
      "test": "test"
    },
    "dependencies": {
       "array-flatten": "^2.1.0",
       "colors": "^1.1.2",
       "minimatch": "^3.0.3",
    },
    "devDependencies": {}
  },

~/Project/src/foo.js:

import colors from 'colors';
import flatten from 'array-flatten';
import minimatch from 'minimatch';

then from the command line:

$:~/www/client1/Project$ depstat --es6

depstat automatically searches through all js files in the ./src directory

the result:

times ref.      dep name                                           format    
___________________________________________________________________________
1               colors                                             es6  
___________________________________________________________________________
1               array-flatten                                      es6  
___________________________________________________________________________
1               minimatch                                          es6