@commitlint/load
Advanced tools
Comparing version 19.1.0 to 19.2.0
@@ -25,4 +25,4 @@ import path from 'path'; | ||
const loaded = await loadConfig(cwd, options.file); | ||
const baseDirectory = (loaded === null || loaded === void 0 ? void 0 : loaded.filepath) ? path.dirname(loaded.filepath) : cwd; | ||
const configFilePath = loaded === null || loaded === void 0 ? void 0 : loaded.filepath; | ||
const baseDirectory = loaded?.filepath ? path.dirname(loaded.filepath) : cwd; | ||
const configFilePath = loaded?.filepath; | ||
let config = {}; | ||
@@ -42,3 +42,6 @@ if (loaded) { | ||
const resolvedParserPreset = resolveFrom(config.parserPreset, configFilePath); | ||
config.parserPreset = Object.assign({ name: config.parserPreset }, (await loadParserPreset(resolvedParserPreset))); | ||
config.parserPreset = { | ||
name: config.parserPreset, | ||
...(await loadParserPreset(resolvedParserPreset)), | ||
}; | ||
} | ||
@@ -45,0 +48,0 @@ // Resolve extends key |
@@ -6,2 +6,3 @@ import { existsSync, readFileSync } from 'fs'; | ||
const moduleName = 'commitlint'; | ||
const searchStrategy = 'global'; | ||
export async function loadConfig(cwd, configPath) { | ||
@@ -21,2 +22,3 @@ let tsLoaderInstance; | ||
const explorer = cosmiconfig(moduleName, { | ||
searchStrategy, | ||
searchPlaces: [ | ||
@@ -26,2 +28,3 @@ // cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files), | ||
'package.json', | ||
'package.yaml', | ||
`.${moduleName}rc`, | ||
@@ -71,3 +74,2 @@ `.${moduleName}rc.json`, | ||
export const isEsmModule = (cwd) => { | ||
var _a; | ||
const packagePath = path.join(cwd, 'package.json'); | ||
@@ -78,4 +80,4 @@ if (!existsSync(packagePath)) { | ||
const packageJSON = readFileSync(packagePath, { encoding: 'utf-8' }); | ||
return ((_a = JSON.parse(packageJSON)) === null || _a === void 0 ? void 0 : _a.type) === 'module'; | ||
return JSON.parse(packageJSON)?.type === 'module'; | ||
}; | ||
//# sourceMappingURL=load-config.js.map |
@@ -36,3 +36,6 @@ function isObjectLike(obj) { | ||
const result = parser.parserOpts((_, opts) => { | ||
resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts })); | ||
resolve({ | ||
...parser, | ||
parserOpts: opts?.parserOpts, | ||
}); | ||
}); | ||
@@ -43,3 +46,6 @@ // If result has data or a promise, the parser doesn't support factory-init | ||
Promise.resolve(result).then((opts) => { | ||
resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts })); | ||
resolve({ | ||
...parser, | ||
parserOpts: opts?.parserOpts, | ||
}); | ||
}); | ||
@@ -46,0 +52,0 @@ } |
@@ -35,3 +35,3 @@ import { createRequire } from 'module'; | ||
console.error(chalk.red(`Failed to load plugin ${longName}.`)); | ||
const message = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error occurred'; | ||
const message = error?.message || 'Unknown error occurred'; | ||
throw new MissingPluginError(pluginName, message, { | ||
@@ -38,0 +38,0 @@ pluginName: longName, |
export class WhitespacePluginError extends Error { | ||
__proto__ = Error; | ||
messageTemplate = 'whitespace-found'; | ||
messageData = {}; | ||
constructor(pluginName, data = {}) { | ||
super(`Whitespace found in plugin name '${pluginName}'`); | ||
this.__proto__ = Error; | ||
this.messageTemplate = 'whitespace-found'; | ||
this.messageData = {}; | ||
this.messageData = data; | ||
@@ -12,6 +12,7 @@ Object.setPrototypeOf(this, WhitespacePluginError.prototype); | ||
export class MissingPluginError extends Error { | ||
__proto__ = Error; | ||
messageTemplate = 'plugin-missing'; | ||
messageData; | ||
constructor(pluginName, errorMessage = '', data = {}) { | ||
super(`Failed to load plugin ${pluginName}: ${errorMessage}`); | ||
this.__proto__ = Error; | ||
this.messageTemplate = 'plugin-missing'; | ||
this.messageData = data; | ||
@@ -18,0 +19,0 @@ Object.setPrototypeOf(this, MissingPluginError.prototype); |
{ | ||
"name": "@commitlint/load", | ||
"type": "module", | ||
"version": "19.1.0", | ||
"version": "19.2.0", | ||
"description": "Load shared commitlint configuration", | ||
@@ -53,3 +53,3 @@ "main": "lib/load.js", | ||
"chalk": "^5.3.0", | ||
"cosmiconfig": "^8.3.6", | ||
"cosmiconfig": "^9.0.0", | ||
"cosmiconfig-typescript-loader": "^5.0.0", | ||
@@ -60,3 +60,3 @@ "lodash.isplainobject": "^4.0.6", | ||
}, | ||
"gitHead": "8d7a3d5d49ab77733e166cb5f195b1b7f277b4a7" | ||
"gitHead": "a64b417b58b3b1e89f07ff529a29a4af223e9369" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
438
36290
+ Addedcosmiconfig@9.0.0(transitive)
+ Addedenv-paths@2.2.1(transitive)
- Removedcosmiconfig@8.3.6(transitive)
- Removedpath-type@4.0.0(transitive)
Updatedcosmiconfig@^9.0.0