Comparing version 0.0.1 to 0.0.2
17
index.js
@@ -5,2 +5,5 @@ // builtin | ||
// node 0.6 support | ||
fs.existsSync = fs.existsSync || path.existsSync; | ||
// main_paths are the paths where our mainprog will be able to load from | ||
@@ -10,6 +13,3 @@ // we store these to avoid grabbing the modules that were loaded as a result | ||
// mainprog loads | ||
// remove trailing node_modules | ||
var main_paths = require.main.paths.map(function(p) { | ||
return path.dirname(p); | ||
}); | ||
var main_paths = require.main.paths; | ||
@@ -29,5 +29,6 @@ module.exports = function() { | ||
(function updir() { | ||
dir = path.dirname(dir); | ||
var orig = dir; | ||
dir = path.dirname(orig); | ||
if (!dir || seen[dir]) { | ||
if (!dir || orig === dir || seen[orig]) { | ||
return; | ||
@@ -39,6 +40,6 @@ } | ||
var pkgfile = path.join(dir, 'package.json'); | ||
var pkgfile = path.join(orig, 'package.json'); | ||
var exists = fs.existsSync(pkgfile); | ||
seen[dir] = true; | ||
seen[orig] = true; | ||
@@ -45,0 +46,0 @@ // travel up the tree if no package.json here |
{ | ||
"name": "lsmod", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "fetch list of modules and versions installed for the project root", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,6 +0,6 @@ | ||
# lsmod | ||
# lsmod [![Build Status](https://secure.travis-ci.org/shtylman/node-lsmod.png?branch=master)](https://travis-ci.org/shtylman/node-lsmod) | ||
lsmod fetches the list of modules and the versions loaded by the entry file for your node.js app. | ||
# use | ||
## use | ||
@@ -18,3 +18,2 @@ ```javascript | ||
} | ||
}); | ||
``` | ||
@@ -24,3 +23,3 @@ | ||
# install via [npm](https://npmjs.org) | ||
## install via [npm](https://npmjs.org) | ||
@@ -27,0 +26,0 @@ ``` |
10
test.js
@@ -0,1 +1,5 @@ | ||
// mocha puts itself as main, we don't want that | ||
require.main.paths.shift(); | ||
require.main.paths.shift(); | ||
var assert = require('assert'); | ||
@@ -6,3 +10,7 @@ var lsmod = require('./'); | ||
var modules = lsmod(); | ||
assert.equal(modules.lsmod, require('./package.json').version); | ||
// our own module is not present because it is not in node_modules | ||
assert.equal(modules.lsmod, undefined); | ||
// mocha is the only thing we have | ||
assert.equal(modules.mocha, '1.7.4'); | ||
@@ -9,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3168
6
56
27