autoresolve
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -0,3 +1,7 @@ | ||
0.0.2 / 2012-07-17 | ||
------------------ | ||
* Bug fix: error if an absolute directory was passed in. | ||
0.0.1 / 2012-07-17 | ||
------------------ | ||
* Inital release. |
@@ -8,3 +8,5 @@ var fs = require('fs'), | ||
module.exports = function(package) { | ||
module.exports = function(packagePath) { | ||
if (packagePath.indexOf('.') === 0 || packagePath.indexOf('/') === 0) | ||
return packagePath; | ||
var DIR = process.cwd(); | ||
@@ -28,4 +30,4 @@ var found = false; | ||
//console.log(DIR); | ||
return path.join(DIR, package); | ||
return path.join(DIR, packagePath); | ||
} | ||
{ | ||
"name" : "autoresolve", | ||
"version" : "0.0.1", | ||
"version" : "0.0.2", | ||
"description" : "A simple module to auto resolve module paths.", | ||
@@ -5,0 +5,0 @@ "homepage" : [ |
@@ -10,2 +10,3 @@ Node.js - autoresolve | ||
var somepack = require(path.join(process.cwd(), 'lib/models/customer')); | ||
``` | ||
@@ -12,0 +13,0 @@ Installation |
var assert = require('assert'), | ||
P = require('../lib/autoresolve'); | ||
P = require('../lib/autoresolve'), | ||
fs = require('fs'); | ||
@@ -7,6 +8,21 @@ var T = function(expr) { assert(expr); }; | ||
describe('+ P()', function(){ | ||
it("should return the proper path.", function(){ | ||
it("should return the proper relative path.", function(){ | ||
var customer = require(P('lib/models/customer')); | ||
T(customer.getName() === 'JP'); | ||
}); | ||
it ("should return the absolute path.", function(done){ | ||
var path = P('lib/models/customer.js'); | ||
var fdr = fs.createReadStream(path); | ||
var fdw = fs.createWriteStream('/tmp/customer.js'); | ||
fdr.on('end', function(){ | ||
var customer = require(P('/tmp/customer')); | ||
fs.unlinkSync('/tmp/customer.js'); | ||
T(customer.getName() === 'JP'); | ||
done(); | ||
}); | ||
fdr.pipe(fdw); | ||
}) | ||
}); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4508
49
36
4