cspell 8.19.2 → 8.19.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.
@@ -6,7 +6,8 @@ import { getFeatureFlags, parseFeatureFlags } from './featureFlags/index.js';
6
6
  import { LintRequest, runLint } from './lint/index.js';
7
7
  import { fixLegacy } from './options.js';
8
8
  import { simpleRepl } from './repl/index.js';
9
- import { fileInfoToDocument, readConfig, readFileInfo } from './util/fileHelper.js';
9
+ import { readConfig } from './util/configFileHelper.js';
10
+ import { fileInfoToDocument, readFileInfo } from './util/fileHelper.js';
10
11
  import { finalizeReporter } from './util/reporters.js';
11
12
  import { readStdin } from './util/stdin.js';
12
13
  import { getTimeMeasurer } from './util/timer.js';
@@ -17,6 +17,14 @@ export interface CSpellEnvironmentVariables {
17
17
  */
18
18
  CSPELL_ENABLE_DICTIONARY_LOG_FIELDS?: string;
19
19
  CSPELL_GLOB_ROOT?: string;
20
+ /**
21
+ * Path to a specific CSpell config file.
22
+ */
23
+ CSPELL_CONFIG_PATH?: string;
24
+ /**
25
+ * Path to the default CSpell config file, used if no other config is found.
26
+ */
27
+ CSPELL_DEFAULT_CONFIG_PATH?: string;
20
28
  }
21
29
  export type EnvironmentKeys = keyof CSpellEnvironmentVariables;
22
30
  type EnvironmentKeyNames = {
@@ -3,6 +3,8 @@ export const environmentKeys = {
3
3
  CSPELL_ENABLE_DICTIONARY_LOG_FILE: 'CSPELL_ENABLE_DICTIONARY_LOG_FILE',
4
4
  CSPELL_ENABLE_DICTIONARY_LOG_FIELDS: 'CSPELL_ENABLE_DICTIONARY_LOG_FIELDS',
5
5
  CSPELL_GLOB_ROOT: 'CSPELL_GLOB_ROOT',
6
+ CSPELL_CONFIG_PATH: 'CSPELL_CONFIG_PATH',
7
+ CSPELL_DEFAULT_CONFIG_PATH: 'CSPELL_DEFAULT_CONFIG_PATH',
6
8
  };
7
9
  export function getEnvironmentVariables() {
8
10
  return process.env;
@@ -14,8 +14,9 @@ import { getEnvironmentVariable, setEnvironmentVariable, truthy } from '../envir
14
14
  import { getFeatureFlags } from '../featureFlags/index.js';
15
15
  import { npmPackage } from '../pkgInfo.js';
16
16
  import { calcCacheSettings, createCache } from '../util/cache/index.js';
17
+ import { readConfig } from '../util/configFileHelper.js';
17
18
  import { CheckFailed, toApplicationError, toError } from '../util/errors.js';
18
- import { fileInfoToDocument, filenameToUri, findFiles, isBinaryFile, isFile, isNotDir, readConfig, readFileInfo, readFileListFiles, resolveFilename, } from '../util/fileHelper.js';
19
+ import { fileInfoToDocument, filenameToUri, findFiles, isBinaryFile, isFile, isNotDir, readFileInfo, readFileListFiles, resolveFilename, } from '../util/fileHelper.js';
19
20
  import { buildGlobMatcher, extractGlobsFromMatcher, extractPatterns, normalizeFileOrGlobsToRoot, normalizeGlobsToRoot, } from '../util/glob.js';
20
21
  import { prefetchIterable } from '../util/prefetch.js';
21
22
  import { loadReporters, mergeReporters } from '../util/reporters.js';
@@ -1,6 +1,6 @@
1
1
  export { pkgDir } from './dirname.js';
2
2
  export declare const name = "cspell";
3
- export declare const version = "8.19.2";
3
+ export declare const version = "8.19.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.19.2';
4
+ export const version = '8.19.3';
5
5
  export const engines = { node: '>=18' };
6
6
  export const npmPackage = { name, version, engines };
7
7
  //# sourceMappingURL=pkgInfo.js.map
@@ -0,0 +1,15 @@
1
+ import type { CSpellUserSettings } from 'cspell-lib';
2
+ import { CSpellConfigFile } from '../options.js';
3
+ export interface ConfigInfo {
4
+ source: string;
5
+ config: CSpellUserSettings;
6
+ }
7
+ export interface FileConfigInfo {
8
+ configInfo: ConfigInfo;
9
+ filename: string;
10
+ text: string;
11
+ languageIds: string[];
12
+ }
13
+ export declare function readConfig(configFile: string | CSpellConfigFile | undefined, root: string | undefined): Promise<ConfigInfo>;
14
+ export declare function readConfigFile(filename: string | URL): Promise<CSpellConfigFile>;
15
+ //# sourceMappingURL=configFileHelper.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { toFilePathOrHref } from '@cspell/url';
2
+ import * as cspell from 'cspell-lib';
3
+ import { environmentKeys, getEnvironmentVariable } from '../environment.js';
4
+ import { filenameToUrl } from './fileHelper.js';
5
+ export async function readConfig(configFile, root) {
6
+ configFile ??= getEnvironmentVariable(environmentKeys.CSPELL_CONFIG_PATH);
7
+ if (configFile) {
8
+ const cfgFile = typeof configFile === 'string' ? await readConfigHandleError(configFile) : configFile;
9
+ return configFileToConfigInfo(cfgFile);
10
+ }
11
+ const config = await cspell.searchForConfig(root);
12
+ const defaultConfigFile = getEnvironmentVariable(environmentKeys.CSPELL_DEFAULT_CONFIG_PATH);
13
+ if (!config && defaultConfigFile) {
14
+ const cfgFile = await readConfigFile(defaultConfigFile).catch(() => undefined);
15
+ if (cfgFile) {
16
+ return configFileToConfigInfo(cfgFile);
17
+ }
18
+ }
19
+ return { source: config?.__importRef?.filename || 'None found', config: config || {} };
20
+ }
21
+ async function configFileToConfigInfo(cfgFile) {
22
+ const config = await cspell.resolveConfigFileImports(cfgFile);
23
+ const source = toFilePathOrHref(cfgFile.url);
24
+ return { source, config };
25
+ }
26
+ export function readConfigFile(filename) {
27
+ return cspell.readConfigFile(filename);
28
+ }
29
+ async function readConfigHandleError(filename) {
30
+ try {
31
+ return await readConfigFile(filename);
32
+ }
33
+ catch (e) {
34
+ const settings = {
35
+ __importRef: {
36
+ filename: filename.toString(),
37
+ error: e,
38
+ },
39
+ };
40
+ return { url: filenameToUrl(filename), settings };
41
+ }
42
+ }
43
+ //# sourceMappingURL=configFileHelper.js.map
@@ -1,20 +1,7 @@
1
1
  import type { BufferEncoding } from 'cspell-io';
2
- import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
2
+ import type { Document, Issue } from 'cspell-lib';
3
3
  import * as cspell from 'cspell-lib';
4
- import { CSpellConfigFile } from '../options.js';
5
4
  import type { GlobOptions } from './glob.js';
6
- export interface ConfigInfo {
7
- source: string;
8
- config: CSpellUserSettings;
9
- }
10
- export interface FileConfigInfo {
11
- configInfo: ConfigInfo;
12
- filename: string;
13
- text: string;
14
- languageIds: string[];
15
- }
16
- export declare function readConfig(configFile: string | CSpellConfigFile | undefined, root: string | undefined): Promise<ConfigInfo>;
17
- export declare function readConfigFile(filename: string | URL): Promise<CSpellConfigFile>;
18
5
  export interface FileInfo {
19
6
  filename: string;
20
7
  text?: string;
@@ -1,11 +1,10 @@
1
1
  import { promises as fsp } from 'node:fs';
2
2
  import * as path from 'node:path';
3
+ import streamConsumers from 'node:stream/consumers';
3
4
  import { fileURLToPath } from 'node:url';
4
- import { toFileDirURL, toFilePathOrHref, toFileURL } from '@cspell/url';
5
+ import { toFileDirURL, toFileURL } from '@cspell/url';
5
6
  import { readFileText as cioReadFile, toURL } from 'cspell-io';
6
- import * as cspell from 'cspell-lib';
7
7
  import { fileToDocument, isBinaryFile as isUriBinaryFile } from 'cspell-lib';
8
- import getStdin from 'get-stdin';
9
8
  import { asyncAwait, asyncFlatten, asyncMap, asyncPipe, mergeAsyncIterables } from './async.js';
10
9
  import { FileUrlPrefix, STDIN, STDINProtocol, STDINUrlPrefix, UTF8 } from './constants.js';
11
10
  import { IOError, toApplicationError, toError } from './errors.js';
@@ -13,33 +12,6 @@ import { globP } from './glob.js';
13
12
  import { readStdin } from './stdin.js';
14
13
  import { isStdinUrl, resolveStdinUrl } from './stdinUrl.js';
15
14
  import { clean } from './util.js';
16
- export async function readConfig(configFile, root) {
17
- if (configFile) {
18
- const cfgFile = typeof configFile === 'string' ? await readConfigHandleError(configFile) : configFile;
19
- const config = await cspell.resolveConfigFileImports(cfgFile);
20
- const source = toFilePathOrHref(cfgFile.url);
21
- return { source, config };
22
- }
23
- const config = await cspell.searchForConfig(root);
24
- return { source: config?.__importRef?.filename || 'None found', config: config || {} };
25
- }
26
- export function readConfigFile(filename) {
27
- return cspell.readConfigFile(filename);
28
- }
29
- async function readConfigHandleError(filename) {
30
- try {
31
- return await readConfigFile(filename);
32
- }
33
- catch (e) {
34
- const settings = {
35
- __importRef: {
36
- filename: filename.toString(),
37
- error: e,
38
- },
39
- };
40
- return { url: filenameToUrl(filename), settings };
41
- }
42
- }
43
15
  export function fileInfoToDocument(fileInfo, languageId, locale) {
44
16
  const { filename, text } = fileInfo;
45
17
  languageId = languageId || undefined;
@@ -90,7 +62,9 @@ export function resolveFilename(filename, cwd) {
90
62
  }
91
63
  export function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
92
64
  filename = resolveFilename(filename);
93
- const pText = filename.startsWith(STDINProtocol) ? getStdin() : cioReadFile(filename, encoding);
65
+ const pText = filename.startsWith(STDINProtocol)
66
+ ? streamConsumers.text(process.stdin)
67
+ : cioReadFile(filename, encoding);
94
68
  return pText.then((text) => ({ text, filename }), (e) => {
95
69
  const error = toError(e);
96
70
  return handleNotFound && error.code === 'EISDIR'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "8.19.2",
3
+ "version": "8.19.3",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "bin": {
@@ -81,22 +81,21 @@
81
81
  },
82
82
  "homepage": "https://cspell.org/",
83
83
  "dependencies": {
84
- "@cspell/cspell-json-reporter": "8.19.2",
85
- "@cspell/cspell-pipe": "8.19.2",
86
- "@cspell/cspell-types": "8.19.2",
87
- "@cspell/dynamic-import": "8.19.2",
88
- "@cspell/url": "8.19.2",
84
+ "@cspell/cspell-json-reporter": "8.19.3",
85
+ "@cspell/cspell-pipe": "8.19.3",
86
+ "@cspell/cspell-types": "8.19.3",
87
+ "@cspell/dynamic-import": "8.19.3",
88
+ "@cspell/url": "8.19.3",
89
89
  "chalk": "^5.4.1",
90
90
  "chalk-template": "^1.1.0",
91
91
  "commander": "^13.1.0",
92
- "cspell-dictionary": "8.19.2",
93
- "cspell-gitignore": "8.19.2",
94
- "cspell-glob": "8.19.2",
95
- "cspell-io": "8.19.2",
96
- "cspell-lib": "8.19.2",
92
+ "cspell-dictionary": "8.19.3",
93
+ "cspell-gitignore": "8.19.3",
94
+ "cspell-glob": "8.19.3",
95
+ "cspell-io": "8.19.3",
96
+ "cspell-lib": "8.19.3",
97
97
  "fast-json-stable-stringify": "^2.1.0",
98
98
  "file-entry-cache": "^9.1.0",
99
- "get-stdin": "^9.0.0",
100
99
  "semver": "^7.7.1",
101
100
  "tinyglobby": "^0.2.13"
102
101
  },
@@ -111,5 +110,5 @@
111
110
  "micromatch": "^4.0.8",
112
111
  "minimatch": "^9.0.5"
113
112
  },
114
- "gitHead": "f630ececa8cd91420aaaaa81c4ad910039457a06"
113
+ "gitHead": "cb6946b709da590d0c6175f9962799d18aa43e93"
115
114
  }