Comparing version 0.1.4 to 0.1.5
@@ -78,9 +78,10 @@ var fs = require('fs') | ||
function globalResolve(module) { | ||
var modulePath, dirname, prefix | ||
var modulePath, dirname | ||
var prefix = rc('npm').prefix | ||
if (isWin32) { | ||
dirname = path.dirname(process.execPath) | ||
dirname = prefix || path.dirname(process.execPath) | ||
} | ||
else { | ||
prefix = rc('npm').prefix || path.join(process.execPath, '../..') | ||
prefix = prefix || path.join(process.execPath, '../..') | ||
dirname = path.join(prefix, 'lib') | ||
@@ -87,0 +88,0 @@ } |
{ | ||
"name": "requireg", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Require and resolve global modules like a boss", | ||
@@ -11,2 +11,6 @@ "homepage": "http://github.com/h2non/requireg", | ||
"email": "tomas@aparicio.me" | ||
}, | ||
{ | ||
"name": "Eugene Sharygin", | ||
"url": "https://github.com/eush77" | ||
} | ||
@@ -45,4 +49,5 @@ ], | ||
"expect.js": "~0.2.0", | ||
"rewire": "~2.3.1", | ||
"semver": "~2.2.1" | ||
} | ||
} |
@@ -1,6 +0,4 @@ | ||
# requireg | ||
[![Build Status](https://secure.travis-ci.org/h2non/requireg.png?branch=master)][2] | ||
[![NPM version](https://badge.fury.io/js/requireg.png)][3] | ||
# requireg [![Build Status](https://secure.travis-ci.org/h2non/requireg.png?branch=master)][2] [![NPM version](https://badge.fury.io/js/requireg.png)][3] | ||
> Require global modules in node.js like a boss | ||
Require and resolve global modules in node/io.js like a boss | ||
@@ -7,0 +5,0 @@ ## Differences with require() |
var expect = require('expect.js') | ||
var resolvers = require('rewire')('../lib/resolvers') | ||
require.cache[require.resolve('../lib/resolvers')] = { exports: resolvers } | ||
var requiregModule = require('../lib/requireg') | ||
var homeVar = process.platform === 'win32' ? 'USERPROFILE' : 'HOME' | ||
var isWin32 = process.platform === 'win32' | ||
var homeVar = isWin32 ? 'USERPROFILE' : 'HOME' | ||
var homePath = process.env[homeVar] | ||
@@ -91,5 +94,7 @@ | ||
var execPath = process.execPath | ||
var rc = require('rc') | ||
before(function () { | ||
process.execPath = __dirname + '/fixtures/bin/node' | ||
resolvers.__set__('rc', function () { return {} }) | ||
}) | ||
@@ -99,2 +104,3 @@ | ||
process.execPath = execPath | ||
resolvers.__set__('rc', rc) | ||
}) | ||
@@ -113,4 +119,30 @@ | ||
describe('resolve via npm prefix', function () { | ||
var rc = require('rc') | ||
before(function () { | ||
resolvers.__set__('rc', function () { | ||
return { | ||
prefix: __dirname + (isWin32 ? '/fixtures/lib' : '/fixtures') | ||
} | ||
}) | ||
}) | ||
after(function () { | ||
resolvers.__set__('rc', rc) | ||
}) | ||
it('should resolve the beaker package', function () { | ||
expect(requiregModule('beaker')).to.be.true | ||
}) | ||
it('should have the expected module path', function () { | ||
expect(requiregModule.resolve('beaker')) | ||
.to.be.equal(__dirname + '/fixtures/lib/node_modules/beaker/index.js') | ||
}) | ||
}) | ||
}) | ||
}) |
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
11629
218
4
86