UNPKG

textlint

Version:

The pluggable linting tool for text and markdown.

47 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfig = void 0; const module_interop_1 = require("@textlint/module-interop"); const rc_config_loader_1 = require("rc-config-loader"); /** * @param configFileName "textlint" for .textlinrc * @param cwd current working dir * @param configFilePath it is preferred than configFileName * @param moduleResolver */ function loadConfig({ cwd, configFileName, configFilePath, moduleResolver }) { // if specify Config module, use it if (configFilePath) { try { const modulePath = moduleResolver.resolveConfigPackageName(configFilePath); return { config: (0, module_interop_1.moduleInterop)(require(modulePath)), filePath: modulePath }; } catch (error) { // not found config module } } // auto or specify path to config file const result = (0, rc_config_loader_1.rcFile)(configFileName, { configFileName: configFilePath, defaultExtension: [".json", ".js", ".yml"], packageJSON: { fieldName: "textlint" }, cwd }); if (result === undefined) { return { config: {}, filePath: undefined }; } return { config: result.config, filePath: result.filePath }; } exports.loadConfig = loadConfig; //# sourceMappingURL=config-loader.js.map