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

allow to load modules from NODE_PATH #69

Merged
merged 2 commits into from
Apr 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(options) {
// 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);
return require(findup(searchFor, {cwd: path.dirname(config)}));
return require(findup(searchFor, {cwd: path.dirname(config)}) || name);
};
} else {
requireFn = require;
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.9.0",
"description": "Automatically load any gulp plugins in your package.json",
"scripts": {
"test": "mocha"
"test": "NODE_PATH=test/global_modules mocha"
},
"files": [
"index.js"
Expand All @@ -25,7 +25,8 @@
"Sindre Sorhus",
"Julien Fontanet <julien.fontanet@vates.fr>",
"Callum Macrae",
"Hutson Betts"
"Hutson Betts",
"Christian Maniewski"
],
"license": "MIT",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions test/global_modules/gulp-test-global/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = function () {};
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,13 @@ describe('requiring from another directory', 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');
});
});
3 changes: 2 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"gulp-test": "*"
"gulp-test": "*",
"gulp-test-global": "*"
}
}