cspell 8.17.1 → 8.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -145,8 +145,8 @@ Options:
145
145
  -u, --unique Only output the first instance of a word not
146
146
  found in the dictionaries.
147
147
  -e, --exclude <glob> Exclude files matching the glob pattern. This
148
- option can be used multiple times to add
149
- multiple globs.
148
+ option can be used multiple times to add multiple
149
+ globs.
150
150
  --file-list <path or stdin> Specify a list of files to be spell checked. The
151
151
  list is filtered against the glob file patterns.
152
152
  Note: the format is 1 file path per line.
@@ -179,8 +179,7 @@ Options:
179
179
  --gitignore Ignore files matching glob patterns found in
180
180
  .gitignore files.
181
181
  --no-gitignore Do NOT use .gitignore files.
182
- --gitignore-root <path> Prevent searching for .gitignore files past
183
- root.
182
+ --gitignore-root <path> Prevent searching for .gitignore files past root.
184
183
  --validate-directives Validate in-document CSpell directives.
185
184
  --color Force color.
186
185
  --no-color Turn off color.
@@ -259,8 +258,8 @@ Trace words -- Search for words in the configuration and dictionaries.
259
258
  Options:
260
259
  -c, --config <cspell.json> Configuration file to use. By default cspell
261
260
  looks for cspell.json in the current directory.
262
- --locale <locale> Set language locales. i.e. "en,fr" for English
263
- and French, or "en-GB" for British English.
261
+ --locale <locale> Set language locales. i.e. "en,fr" for English and
262
+ French, or "en-GB" for British English.
264
263
  --language-id <language> Use programming language. i.e. "php" or "scala".
265
264
  --allow-compound-words Turn on allowCompoundWords
266
265
  --no-allow-compound-words Turn off allowCompoundWords
@@ -315,7 +314,7 @@ exec git diff --cached --name-only | npx cspell --no-summary --no-progress --no-
315
314
 
316
315
  ## Requirements
317
316
 
318
- cspell needs Node 14 and above.
317
+ CSpell needs Node 18 and above.
319
318
 
320
319
  ## How it works
321
320
 
package/bin.mjs CHANGED
@@ -3,16 +3,17 @@ import { format } from 'node:util';
3
3
 
4
4
  import { CommanderError, program } from 'commander';
5
5
 
6
- import * as app from './dist/esm/app.mjs';
6
+ import { ApplicationError, CheckFailed, run } from './dist/esm/app.mjs';
7
7
 
8
- app.run(program, process.argv).catch((e) => {
9
- if (!(e instanceof CommanderError) && !(e instanceof app.CheckFailed)) {
10
- const msg = e instanceof app.ApplicationError ? e.message : format(e);
8
+ run(program, process.argv).catch((e) => {
9
+ if (!(e instanceof CommanderError) && !(e instanceof CheckFailed)) {
10
+ const verbose = process.argv.includes('--verbose') || process.argv.includes('-v');
11
+ const msg = !verbose && e instanceof ApplicationError ? e.message : format(e);
11
12
  process.stdout.write(msg + '\n');
12
13
  // It is possible an explicit exit code was set, use it if it was.
13
14
  process.exitCode = process.exitCode || 1;
14
15
  }
15
- if (e instanceof app.CheckFailed) {
16
+ if (e instanceof CheckFailed) {
16
17
  process.exitCode = e.exitCode;
17
18
  }
18
19
  });
@@ -205,14 +205,15 @@ function augmentCommandHelp(context) {
205
205
  const showHidden = !!opts.verbose;
206
206
  const hiddenHelp = [];
207
207
  const help = command.createHelp();
208
+ help.helpWidth = process.stdout.columns || 80;
208
209
  const hiddenOptions = command.options.filter((opt) => opt.hidden && showHidden);
209
210
  const flagColWidth = Math.max(...command.options.map((opt) => opt.flags.length), 0);
210
- const indent = flagColWidth + 4;
211
+ // const indent = flagColWidth + 4;
211
212
  for (const options of hiddenOptions) {
212
213
  if (!hiddenHelp.length) {
213
214
  hiddenHelp.push('\nHidden Options:');
214
215
  }
215
- hiddenHelp.push(help.wrap(` ${options.flags.padEnd(flagColWidth)} ${options.description}`, process.stdout.columns || 80, indent));
216
+ hiddenHelp.push(help.formatItem(options.flags, flagColWidth, options.description, help));
216
217
  }
217
218
  output.push(...hiddenHelp, advanced);
218
219
  return helpIssueTemplate(opts) + output.join('\n');
@@ -1,4 +1,8 @@
1
1
  import type { RunResult } from '@cspell/cspell-types';
2
2
  import type { LintRequest } from './LintRequest.js';
3
3
  export declare function runLint(cfg: LintRequest): Promise<RunResult>;
4
+ export declare class LinterError extends Error {
5
+ constructor(message: string);
6
+ toString(): string;
7
+ }
4
8
  //# sourceMappingURL=lint.d.ts.map
@@ -88,7 +88,7 @@ export async function runLint(cfg) {
88
88
  const fileInfo = prefetch?.fileInfo || (await readFileInfo(filename, undefined, true));
89
89
  if (fileInfo.errorCode) {
90
90
  if (fileInfo.errorCode !== 'EISDIR' && cfg.options.mustFindFiles) {
91
- const err = toError(`File not found: "${filename}"`);
91
+ const err = new LinterError(`File not found: "${filename}"`);
92
92
  reporter.error('Linter:', err);
93
93
  result.errors += 1;
94
94
  }
@@ -541,4 +541,12 @@ async function writeDictionaryLog() {
541
541
  function globPattern(g) {
542
542
  return typeof g === 'string' ? g : g.glob;
543
543
  }
544
+ export class LinterError extends Error {
545
+ constructor(message) {
546
+ super(message);
547
+ }
548
+ toString() {
549
+ return this.message;
550
+ }
551
+ }
544
552
  //# sourceMappingURL=lint.js.map
@@ -1,6 +1,6 @@
1
1
  export { pkgDir } from './dirname.js';
2
2
  export declare const name = "cspell";
3
- export declare const version = "8.17.1";
3
+ export declare const version = "8.17.3";
4
4
  export declare const engines: {
5
5
  node: string;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  // This file is generated by tools/patch-version.mjs
2
2
  export { pkgDir } from './dirname.js';
3
3
  export const name = 'cspell';
4
- export const version = '8.17.1';
4
+ export const version = '8.17.3';
5
5
  export const engines = { node: '>=18' };
6
6
  export const npmPackage = { name, version, engines };
7
7
  //# sourceMappingURL=pkgInfo.js.map
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
2
  import { stat } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { isError } from '../errors.js';
4
+ import { isErrorLike } from '../errors.js';
5
5
  import { DiskCache } from './DiskCache.js';
6
6
  import { DummyCache } from './DummyCache.js';
7
7
  // cspell:word cspellcache
@@ -47,7 +47,7 @@ async function resolveCacheLocation(cacheLocation) {
47
47
  return path.join(cacheLocation, DEFAULT_CACHE_LOCATION);
48
48
  }
49
49
  catch (err) {
50
- if (isError(err) && err.code === 'ENOENT') {
50
+ if (isErrorLike(err) && err.code === 'ENOENT') {
51
51
  return cacheLocation;
52
52
  }
53
53
  throw err;
@@ -15,6 +15,7 @@ export declare class IOError extends ApplicationError {
15
15
  }
16
16
  export declare function toError(e: unknown): NodeError;
17
17
  export declare function isError(e: unknown): e is NodeError;
18
+ export declare function isErrorLike(e: unknown): e is NodeError;
18
19
  export declare function toApplicationError(e: unknown, message?: string): ApplicationError;
19
20
  export interface NodeError extends Error {
20
21
  code?: string;
@@ -31,14 +31,19 @@ export class IOError extends ApplicationError {
31
31
  export function toError(e) {
32
32
  if (isError(e))
33
33
  return e;
34
+ if (isErrorLike(e)) {
35
+ const ex = new Error(e.message, { cause: e });
36
+ if (e.code !== undefined)
37
+ ex.code = e.code;
38
+ return ex;
39
+ }
34
40
  const message = format(e);
35
- return {
36
- name: 'error',
37
- message,
38
- toString: () => message,
39
- };
41
+ return new Error(message);
40
42
  }
41
43
  export function isError(e) {
44
+ return e instanceof Error;
45
+ }
46
+ export function isErrorLike(e) {
42
47
  if (e instanceof Error)
43
48
  return true;
44
49
  if (!e || typeof e !== 'object')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "8.17.1",
3
+ "version": "8.17.3",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "bin": {
@@ -81,19 +81,19 @@
81
81
  },
82
82
  "homepage": "https://cspell.org/",
83
83
  "dependencies": {
84
- "@cspell/cspell-json-reporter": "8.17.1",
85
- "@cspell/cspell-pipe": "8.17.1",
86
- "@cspell/cspell-types": "8.17.1",
87
- "@cspell/dynamic-import": "8.17.1",
88
- "@cspell/url": "8.17.1",
89
- "chalk": "^5.3.0",
84
+ "@cspell/cspell-json-reporter": "8.17.3",
85
+ "@cspell/cspell-pipe": "8.17.3",
86
+ "@cspell/cspell-types": "8.17.3",
87
+ "@cspell/dynamic-import": "8.17.3",
88
+ "@cspell/url": "8.17.3",
89
+ "chalk": "^5.4.1",
90
90
  "chalk-template": "^1.1.0",
91
- "commander": "^12.1.0",
92
- "cspell-dictionary": "8.17.1",
93
- "cspell-gitignore": "8.17.1",
94
- "cspell-glob": "8.17.1",
95
- "cspell-io": "8.17.1",
96
- "cspell-lib": "8.17.1",
91
+ "commander": "^13.1.0",
92
+ "cspell-dictionary": "8.17.3",
93
+ "cspell-gitignore": "8.17.3",
94
+ "cspell-glob": "8.17.3",
95
+ "cspell-io": "8.17.3",
96
+ "cspell-lib": "8.17.3",
97
97
  "fast-json-stable-stringify": "^2.1.0",
98
98
  "file-entry-cache": "^9.1.0",
99
99
  "get-stdin": "^9.0.0",
@@ -111,5 +111,5 @@
111
111
  "micromatch": "^4.0.8",
112
112
  "minimatch": "^9.0.5"
113
113
  },
114
- "gitHead": "476a03accde11d8bb97c2fd09322f962c83b116a"
114
+ "gitHead": "9a0d2b4584112b33d137faa98e9931ad4e7b6050"
115
115
  }