Socket
Socket
Sign inDemoInstall

@commitlint/cli

Package Overview
Dependencies
Maintainers
4
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commitlint/cli - npm Package Compare versions

Comparing version 19.4.1 to 19.5.0

11

lib/cli-error.d.ts

@@ -0,7 +1,14 @@

export declare enum ExitCode {
CommitlintDefault = 0,
CommitlintErrorDefault = 1,
CommitLintWarning = 2,
CommitLintError = 3,
CommitlintInvalidArgument = 9
}
export declare class CliError extends Error {
__proto__: ErrorConstructor;
type: string;
error_code: number;
constructor(message: string, type: string, error_code?: number);
error_code: ExitCode;
constructor(message: string, type: string, error_code?: ExitCode);
}
//# sourceMappingURL=cli-error.d.ts.map

@@ -0,1 +1,9 @@

export var ExitCode;
(function (ExitCode) {
ExitCode[ExitCode["CommitlintDefault"] = 0] = "CommitlintDefault";
ExitCode[ExitCode["CommitlintErrorDefault"] = 1] = "CommitlintErrorDefault";
ExitCode[ExitCode["CommitLintWarning"] = 2] = "CommitLintWarning";
ExitCode[ExitCode["CommitLintError"] = 3] = "CommitLintError";
ExitCode[ExitCode["CommitlintInvalidArgument"] = 9] = "CommitlintInvalidArgument";
})(ExitCode || (ExitCode = {}));
export class CliError extends Error {

@@ -5,3 +13,3 @@ __proto__ = Error;

error_code;
constructor(message, type, error_code = 1) {
constructor(message, type, error_code = ExitCode.CommitlintErrorDefault) {
super(message);

@@ -8,0 +16,0 @@ this.type = type;

32

lib/cli.js

@@ -8,5 +8,5 @@ import { createRequire } from 'module';

import read from '@commitlint/read';
import { execa } from 'execa';
import { x } from 'tinyexec';
import yargs from 'yargs';
import { CliError } from './cli-error.js';
import { CliError, ExitCode } from './cli-error.js';
const require = createRequire(import.meta.url);

@@ -228,17 +228,15 @@ const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');

if (flags.edit) {
try {
const { stdout } = await execa('git', ['config', 'core.commentChar']);
opts.parserOpts.commentChar = stdout.trim() || gitDefaultCommentChar;
}
catch (e) {
const execaError = e;
// git config returns exit code 1 when the setting is unset,
// don't warn in this case.
if (!execaError.failed || execaError.exitCode !== 1) {
console.warn('Could not determine core.commentChar git configuration', e);
}
const result = x('git', ['config', 'core.commentChar']);
const output = await result;
if (result.exitCode && result.exitCode > 1) {
console.warn('Could not determine core.commentChar git configuration', output.stderr);
opts.parserOpts.commentChar = gitDefaultCommentChar;
}
else {
opts.parserOpts.commentChar =
output.stdout.trim() || gitDefaultCommentChar;
}
}
const results = await Promise.all(messages.map((message) => lint(message, loaded.rules, opts)));
let isRulesEmpty = false;
if (Object.keys(loaded.rules).length === 0) {

@@ -266,2 +264,3 @@ let input = '';

});
isRulesEmpty = true;
}

@@ -291,8 +290,11 @@ const report = results.reduce((info, result) => {

if (report.errorCount > 0) {
throw new CliError(output, pkg.name, 3);
throw new CliError(output, pkg.name, ExitCode.CommitLintError);
}
if (report.warningCount > 0) {
throw new CliError(output, pkg.name, 2);
throw new CliError(output, pkg.name, ExitCode.CommitLintWarning);
}
}
if (isRulesEmpty) {
throw new CliError(output, pkg.name, ExitCode.CommitlintInvalidArgument);
}
if (!report.valid) {

@@ -299,0 +301,0 @@ throw new CliError(output, pkg.name);

{
"name": "@commitlint/cli",
"type": "module",
"version": "19.4.1",
"version": "19.5.0",
"description": "Lint your commit messages",

@@ -42,4 +42,4 @@ "files": [

"devDependencies": {
"@commitlint/test": "^19.0.0",
"@commitlint/utils": "^19.0.0",
"@commitlint/test": "^19.5.0",
"@commitlint/utils": "^19.5.0",
"@types/lodash.merge": "^4.6.8",

@@ -52,11 +52,11 @@ "@types/node": "^18.19.17",

"dependencies": {
"@commitlint/format": "^19.3.0",
"@commitlint/lint": "^19.4.1",
"@commitlint/load": "^19.4.0",
"@commitlint/read": "^19.4.0",
"@commitlint/types": "^19.0.3",
"execa": "^8.0.1",
"@commitlint/format": "^19.5.0",
"@commitlint/lint": "^19.5.0",
"@commitlint/load": "^19.5.0",
"@commitlint/read": "^19.5.0",
"@commitlint/types": "^19.5.0",
"tinyexec": "^0.3.0",
"yargs": "^17.0.0"
},
"gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc"
"gitHead": "7e79af18b7500cda0e38f35944ee08b0b312c006"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc