Zhouyiping 5a7c95461a first commit преди 3 дни
..
example 5a7c95461a first commit преди 3 дни
test 5a7c95461a first commit преди 3 дни
.travis.yml 5a7c95461a first commit преди 3 дни
LICENSE 5a7c95461a first commit преди 3 дни
README.md 5a7c95461a first commit преди 3 дни
index.js 5a7c95461a first commit преди 3 дни
package.json 5a7c95461a first commit преди 3 дни

README.md

find-parent-dir build status

Finds the first parent directory that contains a given file or directory.

npm install find-parent-dir
// assuming this is called from a file in a subdirectory of /myprojects/foo which contains .git directory
var findParentDir = require('find-parent-dir');

findParentDir(__dirname, '.git', function (err, dir) {
  // has err if some file access error occurred
  console.log(dir); // => /myprojects/foo/
  
  // if parent dir wasn't found, dir is null
})

// Same using `sync` method
var dir;
try { 
  dir = findParentDir.sync(__dirname, '.git');
  console.log(dir); // => /myprojects/foo/
  // if parent dir wasn't found, dir is null
} catch(err) {
  console.error('error', err); 
}