Add production dependencies
This commit is contained in:
parent
5a0114f3e2
commit
579ccdc29f
12113 changed files with 978046 additions and 3 deletions
48
node_modules/require-dot-file/index.js
generated
vendored
Normal file
48
node_modules/require-dot-file/index.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
var
|
||||
fs = require('fs'),
|
||||
path = require('path')
|
||||
;
|
||||
|
||||
// walks parent folders until a dot file is found
|
||||
module.exports = function(file, directory, maxSteps) {
|
||||
var
|
||||
steps = 0,
|
||||
requirePath,
|
||||
walk
|
||||
;
|
||||
|
||||
// recursion safety-net
|
||||
maxSteps = maxSteps || 20;
|
||||
|
||||
walk = function(directory) {
|
||||
var
|
||||
nextDirectory = path.resolve( path.join(directory, path.sep, '..') ),
|
||||
currentPath = path.normalize( path.join(directory, file) )
|
||||
;
|
||||
if( fs.existsSync(currentPath) ) {
|
||||
// found file
|
||||
requirePath = path.normalize(currentPath);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// reached file system root, let's stop
|
||||
if(nextDirectory == directory || steps >= maxSteps ) {
|
||||
return;
|
||||
}
|
||||
// otherwise recurse
|
||||
steps++;
|
||||
walk(nextDirectory, file);
|
||||
}
|
||||
};
|
||||
|
||||
// start walk from outside require-dot-files directory
|
||||
directory = directory || path.join(__dirname, path.sep , '..');
|
||||
walk(directory);
|
||||
|
||||
if(!requirePath) {
|
||||
// throw new Error('Unable to find: ' + file);
|
||||
return false;
|
||||
}
|
||||
return require(requirePath);
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue