redfin/npm-detect

Name: npm-detect

Owner: Redfin

Description: An npm package for detecting npm package dependencies.

Created: 2016-07-01 19:51:58.0

Updated: 2016-07-01 19:51:59.0

Pushed: 2011-04-07 00:39:35.0

Homepage: https://github.com/tfe/npm-detect

Size: 302

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

npm-detect

An npm package for walking a project directory (tree of files) and determining which npm packages are depended on by the project files. It will also generate a sample dependencies section suited for inclusion in the project's package.json file (see npm help json for details).

The implementation is very naive, but should work for most cases:

  1. Walk the directory tree, looking for *.js files.
  2. Look for require() statements that match the pattern for npm package names.
  3. Query the npm registry for matching package names.
Installation and Usage

Install via npm:

sudo npm install detect

Run it (example is npm-detect being run on itself):

$ cd /your/project/dir
$ npm-detect
Scanning directory /your/project/dir... 
  ./bin/detect.js
  ./lib/tree-walk.js
Finished scanning, checking 6 packages against npm registry (be patient)...
  path...
  fs...
  child_process...
  util...
  npm... ?
  step... ?
Finished, 2 npm packages found: 
  npm
  step
Sample package.json dependencies section:
{
  "other package.json sections": "go here",
  "dependencies": {
    "npm": "*",
    "step": "*"
  }
}
To-Do
Contact

Problems, comments, and pull requests all welcome. Find me on GitHub.

Copyright & License

Copyright © 2011 Todd Eichel. Released under the MIT License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.