function findConfigForHtmlFile()

in htmlhint-server/src/server.ts [111:139]


function findConfigForHtmlFile(base: string) {
    var options: any;

    if (fs.existsSync(base)) {

        // find default config file in parent directory
        if (fs.statSync(base).isDirectory() === false) {
            base = path.dirname(base);
        }

        while (base && !options) {
            var tmpConfigFile = path.resolve(base + path.sep, '.htmlhintrc');

            // undefined means we haven't tried to load the config file at this path, so try to load it.
            if (htmlhintrcOptions[tmpConfigFile] === undefined) {
                htmlhintrcOptions[tmpConfigFile] = loadConfigurationFile(tmpConfigFile);
            }

            // defined, non-null value means we found a config file at the given path, so use it.
            if (htmlhintrcOptions[tmpConfigFile]) {
                options = htmlhintrcOptions[tmpConfigFile];
                break;
            }

            base = base.substring(0, base.lastIndexOf(path.sep));
        }
    }
    return options;
}