New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

require-traverser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-traverser - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

test/testFiles/inner/withIndex2.js

4

package.json
{"name":"require-traverser",
"version":"0.1.7",
"version":"0.1.8",
"main": "requireTraverser.js",

@@ -8,3 +8,3 @@ "description": "A library for finding all the nested dependencies of a commonJS/node.js module. Uses 'detective' to traverse files.",

"detective":"",
"resolve":"",
"resolve":"https://github.com/fresheneesz/node-resolve/archive/a5151f0fbeb235e3290d9b84ea706bc72bcec94b.tar.gz",
"async-future":"0.1.3"

@@ -11,0 +11,0 @@ },

@@ -27,3 +27,3 @@ **Status**: API finalized, needs testing

where
* `<directory>` is the directory path from which to search for the module

@@ -40,3 +40,6 @@ * `<module>` is the module to get dependencies from

{<filename>:
{resolved: <dependencies>,
{resolved: [
{relative: <modulePath>, absolute: <absolute filesystem path>},
...
],
unresolved: <require expressions that couldn't be resolved>,

@@ -48,4 +51,31 @@ unfound: <require dependencies that couldn't be found>

Example traversed module:
```
require("./testModule/")
var x = "whatever"
require(x)
require('dep'+'endency')
require("http")
require("url")
```
Example result:
```
{"/home/vagrant/temporaryPackageFolder/node_modules/http-proxy/lib/http-proxy.js":
{"resolved":[
{"relative":"./testModule/","absolute":"/home/vagrant/temporaryPackageFolder/node_modules/testModule/lib/testModule.js"}
],
"unresolved":["'dep'+'endency'", "x"],
"unfound":["http","url"]
}
}
```
`rt` doesn't resolve node.js native libraries (returns them as 'unfound').
Todo
========
* When node-resolve accepts my pull request, switch back to the main repo
How to Contribute!

@@ -75,2 +105,3 @@ ============

* 0.1.8 - fixed a bug resolving modules where there is a folder and javascript file with the same name in the same location
* 0.1.6 - fixed a bug in error handling when initial modules can't be found

@@ -77,0 +108,0 @@

@@ -8,3 +8,3 @@ /* Copyright (c) 2013 Billy Tetrud - Free to use for any purpose: MIT License */

var resolve = require('resolve')
var resolve = Future.wrap(require('resolve'))
var detective = require('detective')

@@ -122,11 +122,10 @@

opts.basedir = directory
return Future.wrap(resolve)(dependency, opts)
.catch(function(e) {
if(e.message.indexOf("Cannot find module") === 0) {
return Future(undefined)
} else {
throw e // unknown error
}
})
return resolve(dependency, opts).catch(function(e) {
if(e.message.indexOf("Cannot find module") === 0) {
return Future(undefined)
} else {
throw e // unknown error
}
})
}

@@ -27,3 +27,3 @@ "use strict";

tr(__dirname, './testFiles/inner/analyzeThis.js', function(e,files) {
//console.dir(files)
//console.dir(files, 10)
//console.dir(e)

@@ -83,3 +83,3 @@ testCallback(t, e,files)

t.ok(keys.length === 7)
t.ok(keys.length === 11, keys.length)

@@ -94,2 +94,6 @@ var analyzeThis = r('inner/analyzeThis.js')

var curl = r('../../../node_modules/curl/src/curl.js')
var withIndex = r('node_modules/withIndex/index.js')
var withPackageJson = r('node_modules/withPackageJson/main.js')
var withIndex2 = r('inner/withIndex2/index.js')
var withPackageJson2 = r('inner/withPackageJson2/main.js')

@@ -108,3 +112,3 @@ function basicTest(filePath, resolved, unresolved, unfound) {

t.test("analyzeThis.js", function() {
var info = basicTest.call(this, analyzeThis, 5, 2, 3)
var info = basicTest.call(this, analyzeThis, 9, 2, 3)
var resolved = info.resolved

@@ -133,2 +137,14 @@

this.ok(resolved[moduleToIndex[dep]].absolute === a)
dep = 'withIndex'
this.ok(dep in moduleToIndex)
this.ok(resolved[moduleToIndex[dep]].absolute === withIndex)
dep = 'withPackageJson'
this.ok(dep in moduleToIndex)
this.ok(resolved[moduleToIndex[dep]].absolute === withPackageJson)
dep = './withIndex2/'
this.ok(dep in moduleToIndex)
this.ok(resolved[moduleToIndex[dep]].absolute === withIndex2, resolved[moduleToIndex[dep]].absolute)
dep = './withPackageJson2/'
this.ok(dep in moduleToIndex)
this.ok(resolved[moduleToIndex[dep]].absolute === withPackageJson2)

@@ -170,2 +186,16 @@ this.ok(info.unresolved[0] === "'dep' + 'endency'")

})
t.test("withIndex", function() {
var info = basicTest.call(this, withIndex, 0, 0, 0)
})
t.test("withPackageJson", function() {
var info = basicTest.call(this, withPackageJson, 0, 0, 0)
})
t.test("withIndex2", function() {
var info = basicTest.call(this, withIndex2, 0, 0, 0)
})
t.test("withPackageJson2", function() {
var info = basicTest.call(this, withPackageJson2, 0, 0, 0)
})
}

@@ -172,0 +202,0 @@

@@ -8,2 +8,7 @@ require('util') // by itself

require('withIndex')
require('withPackageJson')
require('./withIndex2/')
require('./withPackageJson2/')
require("dep"+"endency"); // statement

@@ -10,0 +15,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc