Comparing version 0.1.3 to 0.1.4
@@ -10,13 +10,7 @@ var fs = require('fs') | ||
function requireg(module) { | ||
var moduleExports | ||
try { | ||
moduleExports = require(resolve(module)) | ||
} catch (e) {} | ||
if (moduleExports === undefined) { | ||
return require(resolve(module)) | ||
} catch (e) { | ||
throw new Error("Cannot find global module '"+ module +"'") | ||
} | ||
return moduleExports | ||
} | ||
@@ -30,3 +24,2 @@ | ||
function resolve(module, dirname) { | ||
@@ -43,2 +36,2 @@ var i, resolver, modulePath | ||
return modulePath | ||
} | ||
} |
var fs = require('fs') | ||
var path = require('path') | ||
var resolve = require('resolve').sync | ||
var rc = require('rc') | ||
var isWin32 = process.platform === 'win32' | ||
@@ -39,9 +40,5 @@ | ||
if (!nodePath) { | ||
return | ||
} | ||
if (isWin32) { | ||
nodePath = nodePath.replace(':', ';') | ||
} | ||
if (!nodePath) { return } | ||
if (isWin32) { nodePath = nodePath.replace(':', ';') } | ||
nodePath = nodePath.split(';').map(function (nodepath) { | ||
@@ -53,3 +50,3 @@ return path.normalize(nodepath) | ||
if (modulePath = resolveFn(module, dirname || nodePath[i])) { | ||
break; | ||
break | ||
} | ||
@@ -83,10 +80,13 @@ } | ||
function globalResolve(module) { | ||
var modulePath | ||
var dirname = path.dirname(process.execPath) | ||
var modulePath, dirname, prefix | ||
if (!isWin32) { | ||
dirname = path.join(dirname, '../', 'lib') | ||
if (isWin32) { | ||
dirname = path.dirname(process.execPath) | ||
} | ||
else { | ||
prefix = rc('npm').prefix || path.join(process.execPath, '../..') | ||
dirname = path.join(prefix, 'lib') | ||
} | ||
dirname = path.join(dirname, 'node_modules') | ||
modulePath = resolveFn(module, dirname) | ||
@@ -101,3 +101,3 @@ | ||
if (nodeModules && typeof nodeModules === 'string') { | ||
if (typeof nodeModules === 'string') { | ||
nodeModules = nodeModules.split(';') | ||
@@ -104,0 +104,0 @@ for (i = 0, l = nodeModules.length; i < l; i += 1) { |
{ | ||
"name": "requireg", | ||
"version": "0.1.3", | ||
"description": "Require global modules like a boss", | ||
"version": "0.1.4", | ||
"description": "Require and resolve global modules like a boss", | ||
"homepage": "http://github.com/h2non/requireg", | ||
@@ -34,5 +34,7 @@ "bugs": "https://github.com/h2non/requireg/issues", | ||
"require", | ||
"import" | ||
"import", | ||
"resolve" | ||
], | ||
"dependencies": { | ||
"rc": "~1.0.0", | ||
"resolve": "~0.6.1" | ||
@@ -45,2 +47,2 @@ }, | ||
} | ||
} | ||
} |
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
10518
2
191
+ Addedrc@~1.0.0
+ Addeddeep-extend@0.2.11(transitive)
+ Addedini@1.3.8(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedrc@1.0.3(transitive)
+ Addedstrip-json-comments@0.1.3(transitive)