Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced findup with resolve. #75

Merged
merged 1 commit into from May 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 3 additions & 8 deletions index.js
Expand Up @@ -2,6 +2,7 @@
var multimatch = require('multimatch');
var findup = require('findup-sync');
var path = require('path');
var resolve = require('resolve');

function arrayify(el) {
return Array.isArray(el) ? el : [el];
Expand Down Expand Up @@ -33,14 +34,8 @@ module.exports = function(options) {
requireFn = function (name) {
// This searches up from the specified package.json file, making sure
// the config option behaves as expected. See issue #56.
var searchFor = path.join('node_modules', name);

var src = findup(searchFor, {cwd: path.dirname(config)}) || name;
if (src !== null) {
return require(src);
} else {
throw new Error('Cannot find `' + name + '` in your node_modules!');
}
var src = resolve.sync(name, { basedir: path.dirname(config) });
return require(src);
};
} else {
requireFn = require;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,8 @@
"license": "MIT",
"dependencies": {
"findup-sync": "^0.2.1",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove findup-sync if we don't need it any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still used to find the package.json itself, unfortunately. Tried to work out a way to use a single module, but doesn't seem to be possible.

"multimatch": "2.0.0"
"multimatch": "2.0.0",
"resolve": "^1.1.6"
},
"devDependencies": {
"jshint": "^2.5.1",
Expand Down
10 changes: 0 additions & 10 deletions test/index.js
Expand Up @@ -212,13 +212,3 @@ describe('common functionality', function () {
assert.ok(typeof plugins.test === 'function');
});
});

describe('requiring from global directory', function() {
it('allows you to use the NODE_PATH directory', function() {
if (process.env.NODE_PATH !== 'test/global_modules') {
throw new Error('No NODE_PATH found. Please run the tests using npm test.');
}
var plugins = require('../')();
assert.ok(typeof plugins.testGlobal === 'function');
});
});