UNPKG

sortier

Version:
30 lines (29 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveOptions = resolveOptions; const cosmiconfig_1 = require("cosmiconfig"); const log_utils_js_1 = require("../utilities/log-utils.js"); /** * Resolves and loads the closest sortier config to the filepath provided * @param filepath * @returns The loaded options or a default options object */ function resolveOptions(filepath) { const explorer = (0, cosmiconfig_1.cosmiconfigSync)("sortier", { searchStrategy: "global" }); const result = explorer.search(filepath); const config = result?.config || {}; const options = config; // Set the LogUtils verbosity based on options switch (options?.logLevel) { case "diagnostic": log_utils_js_1.LogUtils.setVerbosity(log_utils_js_1.LoggerVerboseOption.Diagnostic); break; case "quiet": log_utils_js_1.LogUtils.setVerbosity(log_utils_js_1.LoggerVerboseOption.Quiet); break; default: log_utils_js_1.LogUtils.setVerbosity(log_utils_js_1.LoggerVerboseOption.Normal); break; } return options; }