Skip to content

Commit

Permalink
fix: Dump stack on error when verbose (#6782)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Jan 13, 2025
1 parent ab2cdb8 commit df0026c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/cspell/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { format } from 'node:util';

import { CommanderError, program } from 'commander';

import * as app from './dist/esm/app.mjs';
import { ApplicationError, CheckFailed, run } from './dist/esm/app.mjs';

app.run(program, process.argv).catch((e) => {
if (!(e instanceof CommanderError) && !(e instanceof app.CheckFailed)) {
const msg = e instanceof app.ApplicationError ? e.message : format(e);
run(program, process.argv).catch((e) => {
if (!(e instanceof CommanderError) && !(e instanceof CheckFailed)) {
const verbose = process.argv.includes('--verbose') || process.argv.includes('-v');
const msg = !verbose && e instanceof ApplicationError ? e.message : format(e);
process.stdout.write(msg + '\n');
// It is possible an explicit exit code was set, use it if it was.
process.exitCode = process.exitCode || 1;
}
if (e instanceof app.CheckFailed) {
if (e instanceof CheckFailed) {
process.exitCode = e.exitCode;
}
});

0 comments on commit df0026c

Please sign in to comment.