load-config.js 845 B

123456789101112131415161718192021
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.loadConfig = void 0;
  7. const path_1 = __importDefault(require("path"));
  8. const cosmiconfig_1 = require("cosmiconfig");
  9. async function loadConfig(cwd, configPath) {
  10. const explorer = cosmiconfig_1.cosmiconfig('commitlint');
  11. const explicitPath = configPath ? path_1.default.resolve(cwd, configPath) : undefined;
  12. const explore = explicitPath ? explorer.load : explorer.search;
  13. const searchPath = explicitPath ? explicitPath : cwd;
  14. const local = await explore(searchPath);
  15. if (local) {
  16. return local;
  17. }
  18. return null;
  19. }
  20. exports.loadConfig = loadConfig;
  21. //# sourceMappingURL=load-config.js.map