You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
5 months ago | |
---|---|---|
.. | ||
example | 5 months ago | |
test | 5 months ago | |
.npmignore | 5 months ago | |
.travis.yml | 5 months ago | |
LICENSE | 5 months ago | |
README.md | 5 months ago | |
index.js | 5 months ago | |
package.json | 5 months ago |
README.md
find-parent-dir 
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);
}