@commitlint/cli
Advanced tools
Comparing version 19.4.1 to 19.5.0
@@ -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; |
@@ -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
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
32374
450
0
+ Addedtinyexec@^0.3.0
- Removedexeca@^8.0.1
- Removedcross-spawn@7.0.3(transitive)
- Removedexeca@8.0.1(transitive)
- Removedget-stream@8.0.1(transitive)
- Removedhuman-signals@5.0.0(transitive)
- Removedis-stream@3.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedmimic-fn@4.0.0(transitive)
- Removednpm-run-path@5.3.0(transitive)
- Removedonetime@6.0.0(transitive)
- Removedpath-key@3.1.14.0.0(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedsignal-exit@4.1.0(transitive)
- Removedstrip-final-newline@3.0.0(transitive)
- Removedwhich@2.0.2(transitive)
Updated@commitlint/format@^19.5.0
Updated@commitlint/lint@^19.5.0
Updated@commitlint/load@^19.5.0
Updated@commitlint/read@^19.5.0
Updated@commitlint/types@^19.5.0