Comparing version 0.3.1 to 0.3.2
@@ -26,14 +26,7 @@ // For given path returns root package path. | ||
var parent; | ||
if (exists) { | ||
return path; | ||
} else { | ||
parent = dirname(path); | ||
if (parent === path) { | ||
return null; | ||
} else if (basename(parent) === 'node_modules') { | ||
return path; | ||
} else { | ||
return findRoot(parent); | ||
} | ||
} | ||
if (exists) return path; | ||
parent = dirname(path); | ||
if (parent === path) return null; | ||
if (basename(parent) === 'node_modules') return path; | ||
return findRoot(parent); | ||
}); | ||
@@ -40,0 +33,0 @@ }); |
@@ -18,7 +18,4 @@ // Require first named module in tree (traversing up) | ||
if (m) { | ||
if (m instanceof Error) { | ||
throw m; | ||
} else { | ||
return m; | ||
} | ||
if (m instanceof Error) throw m; | ||
return m; | ||
} | ||
@@ -25,0 +22,0 @@ if (path === root) { |
@@ -9,11 +9,12 @@ // Require module in given context | ||
, vm = require('vm') | ||
, memoize = require('memoizee') | ||
, errorMsg = require('./is-module-not-found-error') | ||
, wrap = Module.wrap | ||
, wrap = Module.wrap, get; | ||
, modRequire = Module.prototype.require || function (path) { | ||
return Module._load(path, this); | ||
}; | ||
get = memoize(function (path, context) { | ||
return new Module(path, module); | ||
}); | ||
module.exports = function (path, context) { | ||
module.exports = exports = function (path, context) { | ||
var fmodule, content, dirpath; | ||
@@ -25,18 +26,20 @@ | ||
return require(path); | ||
} else { | ||
dirpath = dirname(path); | ||
fmodule = new Module(path, module); | ||
fmodule.filename = path; | ||
fmodule.paths = Module._nodeModulePaths(dirpath); | ||
fmodule.require = modRequire; | ||
try { | ||
content = readFile(path, 'utf8'); | ||
} catch (e) { | ||
throw new Error(errorMsg.pattern.replace(errorMsg.token, path)); | ||
} | ||
vm.runInContext(wrap(content), context).call(fmodule.exports, | ||
fmodule.exports, fmodule.require.bind(fmodule), fmodule, path, dirpath); | ||
fmodule.loaded = true; | ||
return fmodule.exports; | ||
} | ||
fmodule = get(path, context); | ||
if (fmodule.loaded) return fmodule.exports; | ||
fmodule.filename = path; | ||
dirpath = dirname(path); | ||
fmodule.paths = Module._nodeModulePaths(dirpath); | ||
fmodule.require = function (path) { | ||
return exports(Module._resolveFilename(String(path), this), context); | ||
}; | ||
try { | ||
content = readFile(path, 'utf8'); | ||
} catch (e) { | ||
throw new Error(errorMsg.pattern.replace(errorMsg.token, path)); | ||
} | ||
fmodule.loaded = true; | ||
vm.runInContext(wrap(content), context).call(fmodule.exports, | ||
fmodule.exports, fmodule.require.bind(fmodule), fmodule, path, dirpath); | ||
return fmodule.exports; | ||
}; |
{ | ||
"name": "next", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "(deprecated) Node.js extensions", | ||
@@ -27,5 +27,5 @@ "keywords": [ | ||
"dependencies": { | ||
"deferred": "0.6.x", | ||
"es5-ext": "0.9.x", | ||
"memoizee": "~0.2.2" | ||
"deferred": "~0.6.5", | ||
"es5-ext": "~0.9.2", | ||
"memoizee": "~0.2.5" | ||
}, | ||
@@ -36,5 +36,5 @@ "scripts": { | ||
"devDependencies": { | ||
"tad": "0.1.x" | ||
"tad": "~0.1.16" | ||
}, | ||
"optionalDependencies": {} | ||
"licence": "MIT" | ||
} |
@@ -7,6 +7,5 @@ 'use strict'; | ||
, pgPath, upPath; | ||
, pgPath; | ||
pgPath = resolve(__dirname, '../__playground/module/find-package-root'); | ||
upPath = path.dirname(path.dirname(__dirname)); | ||
@@ -13,0 +12,0 @@ module.exports = { |
'use strict'; | ||
var resolve = require('path').resolve | ||
, isNotFoundError = require('../../lib/module/is-module-not-found-error'); | ||
, isNotFoundError = require('../../lib/module/is-module-not-found-error') | ||
var pg = resolve(__dirname, '../__playground/module/require-first-in-tree'); | ||
, pg = resolve(__dirname, '../__playground/module/require-first-in-tree'); | ||
@@ -8,0 +8,0 @@ module.exports = function (t, a) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
17869
45
0
336
Updateddeferred@~0.6.5
Updatedes5-ext@~0.9.2
Updatedmemoizee@~0.2.5