tasks/php2html.js
function findFile(name, dir) {
        dir = dir || process.cwd();

        var filename = path.normalize(path.join(dir, name));
        if (findFileResults[filename] !== undefined) {
            return findFileResults[filename];
        }

        var parent = path.resolve(dir, "../");

        if (shjs.test("-e", filename)) {
            findFileResults[filename] = filename;
            return filename;
        }

        if (dir === parent) {
            findFileResults[filename] = null;
            return null;
        }

        return findFile(name, parent);
    }
function findFile(name, dir) {
        dir = dir || process.cwd();

        var filename = path.normalize(path.join(dir, name));
        if (findFileResults[filename] !== undefined) {
            return findFileResults[filename];
        }

        var parent = path.resolve(dir, "../");

        if (shjs.test("-e", filename)) {
            findFileResults[filename] = filename;
            return filename;
        }

        if (dir === parent) {
            findFileResults[filename] = null;
            return null;
        }

        return findFile(name, parent);
    }
function findFile ( name , dir ) { dir = dir || process . cwd ( ) ; var filename = path . normalize ( path . join ( dir , name ) ) ; if ( findFileResults [ filename ] !== undefined ) { return findFileResults [ filename ] ; } var parent = path . resolve ( dir , "../" ) ; if ( shjs . test ( "-e" , filename ) ) { findFileResults [ filename ] = filename ; return filename ; } if ( dir === parent ) { findFileResults [ filename ] = null ; return null ; } return findFile ( name , parent ) ; }
Searches for a file with a specified name starting with
'dir' and going all the way up either until it finds the file
or hits the root.

copied from
https://github.com/jshint/jshint/blob/master/src/cli.js

@param {string} name filename to search for (e.g. .jshintrc)
@param {string} dir  directory to start search from (default:
current working directory)

@returns {string} normalized filename
Searches for a file with a specified name starting with dir and going all the way up either until it finds the file or hits the root .