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.
24 lines
794 B
24 lines
794 B
/*
|
|
* grunt
|
|
* http://gruntjs.com/
|
|
*
|
|
* Copyright (c) 2012 "Cowboy" Ben Alman
|
|
* Licensed under the MIT license.
|
|
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
|
|
*/
|
|
|
|
// Nodejs libs.
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
// In Nodejs 0.8.0, existsSync moved from path -> fs.
|
|
var existsSync = fs.existsSync || path.existsSync;
|
|
|
|
// Search for a filename in the given directory or all parent directories.
|
|
module.exports = function findup(dirpath, filename) {
|
|
var filepath = path.join(dirpath, filename);
|
|
// Return file if found.
|
|
if (existsSync(filepath)) { return filepath; }
|
|
// If parentpath is the same as dirpath, we can't go any higher.
|
|
var parentpath = path.resolve(dirpath, '..');
|
|
return parentpath === dirpath ? null : findup(parentpath, filename);
|
|
};
|