cspell 7.0.0-alpha.1 → 7.0.1-alpha.0

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.
Files changed (91) hide show
  1. package/dist/esm/application.d.mts +1 -1
  2. package/dist/esm/cli-reporter.mjs +2 -1
  3. package/dist/esm/util/constants.d.mts +1 -1
  4. package/dist/esm/util/fileHelper.d.mts +1 -1
  5. package/dist/lib/file-entry-cache.cjs +3 -2
  6. package/dist/lib/file-entry-cache.d.cts +2 -2
  7. package/dist/lib/pkgInfo.cjs +3 -25
  8. package/package.json +31 -36
  9. package/bin.js +0 -16
  10. package/dist/cjs/app.d.ts +0 -5
  11. package/dist/cjs/app.js +0 -50
  12. package/dist/cjs/application.d.ts +0 -16
  13. package/dist/cjs/application.js +0 -121
  14. package/dist/cjs/cli-reporter.d.ts +0 -16
  15. package/dist/cjs/cli-reporter.js +0 -247
  16. package/dist/cjs/commandCheck.d.ts +0 -3
  17. package/dist/cjs/commandCheck.js +0 -78
  18. package/dist/cjs/commandLink.d.ts +0 -3
  19. package/dist/cjs/commandLink.js +0 -51
  20. package/dist/cjs/commandLint.d.ts +0 -3
  21. package/dist/cjs/commandLint.js +0 -150
  22. package/dist/cjs/commandSuggestion.d.ts +0 -3
  23. package/dist/cjs/commandSuggestion.js +0 -88
  24. package/dist/cjs/commandTrace.d.ts +0 -3
  25. package/dist/cjs/commandTrace.js +0 -87
  26. package/dist/cjs/emitters/DictionaryPathFormat.d.ts +0 -3
  27. package/dist/cjs/emitters/DictionaryPathFormat.js +0 -16
  28. package/dist/cjs/emitters/suggestionsEmitter.d.ts +0 -13
  29. package/dist/cjs/emitters/suggestionsEmitter.js +0 -84
  30. package/dist/cjs/emitters/traceEmitter.d.ts +0 -21
  31. package/dist/cjs/emitters/traceEmitter.js +0 -171
  32. package/dist/cjs/featureFlags/featureFlags.d.ts +0 -4
  33. package/dist/cjs/featureFlags/featureFlags.js +0 -25
  34. package/dist/cjs/featureFlags/index.d.ts +0 -2
  35. package/dist/cjs/featureFlags/index.js +0 -7
  36. package/dist/cjs/index.d.ts +0 -5
  37. package/dist/cjs/index.js +0 -22
  38. package/dist/cjs/link.d.ts +0 -8
  39. package/dist/cjs/link.js +0 -47
  40. package/dist/cjs/lint/LintRequest.d.ts +0 -23
  41. package/dist/cjs/lint/LintRequest.js +0 -48
  42. package/dist/cjs/lint/index.d.ts +0 -3
  43. package/dist/cjs/lint/index.js +0 -8
  44. package/dist/cjs/lint/lint.d.ts +0 -4
  45. package/dist/cjs/lint/lint.js +0 -499
  46. package/dist/cjs/options.d.ts +0 -178
  47. package/dist/cjs/options.js +0 -12
  48. package/dist/cjs/repl/index.d.ts +0 -18
  49. package/dist/cjs/repl/index.js +0 -75
  50. package/dist/cjs/util/InMemoryReporter.d.ts +0 -28
  51. package/dist/cjs/util/InMemoryReporter.js +0 -47
  52. package/dist/cjs/util/async.d.ts +0 -3
  53. package/dist/cjs/util/async.js +0 -12
  54. package/dist/cjs/util/cache/CSpellLintResultCache.d.ts +0 -20
  55. package/dist/cjs/util/cache/CSpellLintResultCache.js +0 -3
  56. package/dist/cjs/util/cache/CacheOptions.d.ts +0 -34
  57. package/dist/cjs/util/cache/CacheOptions.js +0 -3
  58. package/dist/cjs/util/cache/DiskCache.d.ts +0 -63
  59. package/dist/cjs/util/cache/DiskCache.js +0 -237
  60. package/dist/cjs/util/cache/DummyCache.d.ts +0 -11
  61. package/dist/cjs/util/cache/DummyCache.js +0 -22
  62. package/dist/cjs/util/cache/ObjectCollection.d.ts +0 -17
  63. package/dist/cjs/util/cache/ObjectCollection.js +0 -136
  64. package/dist/cjs/util/cache/createCache.d.ts +0 -31
  65. package/dist/cjs/util/cache/createCache.js +0 -77
  66. package/dist/cjs/util/cache/fileEntryCache.d.ts +0 -9
  67. package/dist/cjs/util/cache/fileEntryCache.js +0 -107
  68. package/dist/cjs/util/cache/index.d.ts +0 -4
  69. package/dist/cjs/util/cache/index.js +0 -8
  70. package/dist/cjs/util/constants.d.ts +0 -6
  71. package/dist/cjs/util/constants.js +0 -8
  72. package/dist/cjs/util/errors.d.ts +0 -23
  73. package/dist/cjs/util/errors.js +0 -60
  74. package/dist/cjs/util/fileHelper.d.ts +0 -63
  75. package/dist/cjs/util/fileHelper.js +0 -226
  76. package/dist/cjs/util/glob.d.ts +0 -45
  77. package/dist/cjs/util/glob.js +0 -175
  78. package/dist/cjs/util/prefetch.d.ts +0 -2
  79. package/dist/cjs/util/prefetch.js +0 -23
  80. package/dist/cjs/util/reporters.d.ts +0 -14
  81. package/dist/cjs/util/reporters.js +0 -68
  82. package/dist/cjs/util/stdin.d.ts +0 -2
  83. package/dist/cjs/util/stdin.js +0 -32
  84. package/dist/cjs/util/table.d.ts +0 -10
  85. package/dist/cjs/util/table.js +0 -40
  86. package/dist/cjs/util/timer.d.ts +0 -8
  87. package/dist/cjs/util/timer.js +0 -17
  88. package/dist/cjs/util/types.d.ts +0 -7
  89. package/dist/cjs/util/types.js +0 -6
  90. package/dist/cjs/util/util.d.ts +0 -13
  91. package/dist/cjs/util/util.js +0 -55
@@ -1,136 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Collection = exports.ShallowObjectCollection = void 0;
5
- const compare = Intl.Collator().compare;
6
- class ShallowObjectCollection {
7
- constructor() {
8
- this.tree = {};
9
- }
10
- get(v) {
11
- if (typeof v !== 'object' || v === null) {
12
- return v;
13
- }
14
- const keys = Object.entries(v)
15
- .filter((entry) => entry[1] !== undefined)
16
- .sort((a, b) => compare(a[0], b[0]));
17
- let t = this.tree;
18
- for (const [key, obj] of keys) {
19
- if (!t.c) {
20
- t.c = new Map();
21
- }
22
- const c0 = t.c.get(key);
23
- const cc = c0 || new Map();
24
- if (!c0) {
25
- t.c.set(key, cc);
26
- }
27
- const c1 = cc.get(obj);
28
- const ccc = c1 || {};
29
- if (!c1) {
30
- cc.set(obj, ccc);
31
- }
32
- t = ccc;
33
- }
34
- if (t.v)
35
- return t.v;
36
- t.v = v;
37
- return v;
38
- }
39
- }
40
- exports.ShallowObjectCollection = ShallowObjectCollection;
41
- class Collection {
42
- constructor() {
43
- this.col = { contains: new Map() };
44
- }
45
- /**
46
- * Add a plain object to the collection.
47
- * The actual object used is returned.
48
- * By adding the object to the collection, it is now owned by the collection.
49
- * Do not add class objects.
50
- * @param v any object or primitive
51
- * @returns v or the matching object.
52
- */
53
- add(v) {
54
- return addToCollection(this.col, v);
55
- }
56
- }
57
- exports.Collection = Collection;
58
- // const objectLike: TypeMask = {
59
- // array: true,
60
- // object: true,
61
- // };
62
- function addToCollection(root, v) {
63
- const known = root.contains;
64
- function addValToCol(c, v) {
65
- const t = toValueType(v);
66
- const val = c.v || Object.create(null);
67
- const r = val[t] ?? v;
68
- val[t] = r;
69
- c.v = val;
70
- return val[t];
71
- }
72
- function walk(col, path) {
73
- path = path.filter((entry) => entry[1] !== undefined).sort((a, b) => compare(a[0], b[0]));
74
- for (const [k, v] of path) {
75
- const c = col.c || Object.create(null);
76
- col.c = c;
77
- const m = c[k] || new Map();
78
- c[k] = m;
79
- const has = m.get(v);
80
- col = has || Object.create(null);
81
- if (!has) {
82
- m.set(v, col);
83
- }
84
- }
85
- return col;
86
- }
87
- function normalizeObjectEntries(entries) {
88
- for (const entry of entries) {
89
- entry[1] = add(entry[1]);
90
- }
91
- return entries;
92
- }
93
- function normalizeToPath(v) {
94
- if (typeof v !== 'object' || !v) {
95
- return [['', v]];
96
- }
97
- const entries = normalizeObjectEntries(Object.entries(v));
98
- const obj = v;
99
- if (!Object.isFrozen(v)) {
100
- for (const [k, v] of entries) {
101
- obj[k] = v;
102
- }
103
- Object.freeze(obj);
104
- }
105
- return entries;
106
- }
107
- function add(v) {
108
- const isObjectLike = typeof v === 'object' && !!v;
109
- if (isObjectLike) {
110
- const cached = known.get(v);
111
- if (cached !== undefined) {
112
- return cached;
113
- }
114
- known.set(v, v);
115
- }
116
- const path = normalizeToPath(v);
117
- const c = walk(root, path);
118
- const r = addValToCol(c, v);
119
- if (isObjectLike) {
120
- known.set(v, r);
121
- }
122
- return r;
123
- }
124
- return add(v);
125
- }
126
- function toValueType(v) {
127
- const t = typeof v;
128
- if (t !== 'object')
129
- return t;
130
- if (v instanceof Array)
131
- return 'array';
132
- if (v === null)
133
- return 'null';
134
- return t;
135
- }
136
- //# sourceMappingURL=ObjectCollection.js.map
@@ -1,31 +0,0 @@
1
- import type { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
2
- import type { CacheOptions } from './CacheOptions.js';
3
- import type { CSpellLintResultCache } from './CSpellLintResultCache.js';
4
- export declare const DEFAULT_CACHE_LOCATION = ".cspellcache";
5
- export interface CreateCacheSettings extends Required<CacheSettings> {
6
- /**
7
- * cspell version used to validate cache entries.
8
- */
9
- version: string;
10
- /**
11
- * When true, causes the cache to be reset, removing any entries
12
- * or cache files.
13
- */
14
- reset?: true;
15
- }
16
- /**
17
- * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
18
- */
19
- export declare function createCache(options: CreateCacheSettings): CSpellLintResultCache;
20
- export declare function calcCacheSettings(config: CSpellSettings, cacheOptions: CacheOptions, root: string): Promise<CreateCacheSettings>;
21
- /**
22
- * Normalizes the version and return only `major.minor + versionSuffix`
23
- * @param version The cspell semantic version.
24
- */
25
- declare function normalizeVersion(version: string): string;
26
- export declare const __testing__: {
27
- normalizeVersion: typeof normalizeVersion;
28
- versionSuffix: string;
29
- };
30
- export {};
31
- //# sourceMappingURL=createCache.d.ts.map
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.__testing__ = exports.calcCacheSettings = exports.createCache = exports.DEFAULT_CACHE_LOCATION = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- const promises_1 = require("fs/promises");
9
- const path_1 = __importDefault(require("path"));
10
- const errors_js_1 = require("../errors.js");
11
- const DiskCache_js_1 = require("./DiskCache.js");
12
- const DummyCache_js_1 = require("./DummyCache.js");
13
- // cspell:word cspellcache
14
- exports.DEFAULT_CACHE_LOCATION = '.cspellcache';
15
- const versionSuffix = '';
16
- /**
17
- * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
18
- */
19
- function createCache(options) {
20
- const { useCache, cacheLocation, cacheStrategy, reset } = options;
21
- const location = path_1.default.resolve(cacheLocation);
22
- const useChecksum = cacheStrategy === 'content';
23
- const version = normalizeVersion(options.version);
24
- const useUniversal = options.cacheFormat === 'universal';
25
- const cache = useCache ? new DiskCache_js_1.DiskCache(location, useChecksum, version, useUniversal) : new DummyCache_js_1.DummyCache();
26
- reset && cache.reset();
27
- return cache;
28
- }
29
- exports.createCache = createCache;
30
- async function calcCacheSettings(config, cacheOptions, root) {
31
- const cs = config.cache ?? {};
32
- const useCache = cacheOptions.cache ?? cs.useCache ?? false;
33
- const cacheLocation = await resolveCacheLocation(path_1.default.resolve(root, cacheOptions.cacheLocation ?? cs.cacheLocation ?? exports.DEFAULT_CACHE_LOCATION));
34
- const cacheStrategy = cacheOptions.cacheStrategy ?? cs.cacheStrategy ?? 'metadata';
35
- const cacheFormat = cacheOptions.cacheFormat ?? cs.cacheFormat ?? 'legacy';
36
- const optionals = {};
37
- if (cacheOptions.cacheReset) {
38
- optionals.reset = true;
39
- }
40
- return {
41
- ...optionals,
42
- useCache,
43
- cacheLocation,
44
- cacheStrategy,
45
- version: cacheOptions.version,
46
- cacheFormat,
47
- };
48
- }
49
- exports.calcCacheSettings = calcCacheSettings;
50
- async function resolveCacheLocation(cacheLocation) {
51
- try {
52
- const s = await (0, promises_1.stat)(cacheLocation);
53
- if (s.isFile())
54
- return cacheLocation;
55
- return path_1.default.join(cacheLocation, exports.DEFAULT_CACHE_LOCATION);
56
- }
57
- catch (err) {
58
- if ((0, errors_js_1.isError)(err) && err.code === 'ENOENT') {
59
- return cacheLocation;
60
- }
61
- throw err;
62
- }
63
- }
64
- /**
65
- * Normalizes the version and return only `major.minor + versionSuffix`
66
- * @param version The cspell semantic version.
67
- */
68
- function normalizeVersion(version) {
69
- const parts = version.split('.').slice(0, 2);
70
- (0, assert_1.default)(parts.length === 2);
71
- return parts.join('.') + versionSuffix;
72
- }
73
- exports.__testing__ = {
74
- normalizeVersion,
75
- versionSuffix,
76
- };
77
- //# sourceMappingURL=createCache.js.map
@@ -1,9 +0,0 @@
1
- /**
2
- * This is a wrapper for 'file-entry-cache'
3
- */
4
- export type { FileDescriptor } from '../../../lib/file-entry-cache.cjs';
5
- import type { FileEntryCache as FecFileEntryCache } from '../../../lib/file-entry-cache.cjs';
6
- export type FileEntryCache = FecFileEntryCache;
7
- export declare function createFromFile(pathToCache: string, useCheckSum: boolean, useRelative: boolean): FileEntryCache;
8
- export declare function normalizePath(filePath: string): string;
9
- //# sourceMappingURL=fileEntryCache.d.ts.map
@@ -1,107 +0,0 @@
1
- "use strict";
2
- /**
3
- * This is a wrapper for 'file-entry-cache'
4
- */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.normalizePath = exports.createFromFile = void 0;
30
- const fs_1 = require("fs");
31
- const path = __importStar(require("path"));
32
- const worker_threads_1 = require("worker_threads");
33
- const fec = __importStar(require("../../../lib/file-entry-cache.cjs"));
34
- function createFromFile(pathToCache, useCheckSum, useRelative) {
35
- const absPathToCache = path.resolve(pathToCache);
36
- const relDir = path.dirname(absPathToCache);
37
- (0, fs_1.mkdirSync)(relDir, { recursive: true });
38
- const create = wrap(() => fec.createFromFile(absPathToCache, useCheckSum));
39
- const feCache = create();
40
- const cacheWrapper = {
41
- get cache() {
42
- return feCache.cache;
43
- },
44
- getHash(buffer) {
45
- return feCache.getHash(buffer);
46
- },
47
- hasFileChanged: wrap((cwd, file) => {
48
- console.log(file);
49
- return feCache.hasFileChanged(resolveFile(cwd, file));
50
- }),
51
- analyzeFiles: wrap((cwd, files) => {
52
- return feCache.analyzeFiles(resolveFiles(cwd, files));
53
- }),
54
- getFileDescriptor: wrap((cwd, file) => {
55
- return feCache.getFileDescriptor(resolveFile(cwd, file));
56
- }),
57
- getUpdatedFiles: wrap((cwd, files) => {
58
- return feCache.getUpdatedFiles(resolveFiles(cwd, files));
59
- }),
60
- normalizeEntries: wrap((cwd, files) => {
61
- return feCache.normalizeEntries(resolveFiles(cwd, files));
62
- }),
63
- removeEntry: wrap((cwd, file) => {
64
- console.log(file);
65
- return feCache.removeEntry(resolveFile(cwd, file));
66
- }),
67
- deleteCacheFile() {
68
- feCache.deleteCacheFile();
69
- },
70
- destroy() {
71
- feCache.destroy();
72
- },
73
- reconcile: wrap((_cwd, noPrune) => {
74
- feCache.reconcile(noPrune);
75
- }),
76
- };
77
- return cacheWrapper;
78
- function resolveFile(cwd, file) {
79
- if (!useRelative)
80
- return file;
81
- const r = path.relative(relDir, path.resolve(cwd, file));
82
- return normalizePath(r);
83
- }
84
- function resolveFiles(cwd, files) {
85
- return files?.map((file) => resolveFile(cwd, file));
86
- }
87
- function wrap(fn) {
88
- return (...params) => {
89
- const cwd = process.cwd();
90
- try {
91
- worker_threads_1.isMainThread && process.chdir(relDir);
92
- return fn(cwd, ...params);
93
- }
94
- finally {
95
- worker_threads_1.isMainThread && process.chdir(cwd);
96
- }
97
- };
98
- }
99
- }
100
- exports.createFromFile = createFromFile;
101
- function normalizePath(filePath) {
102
- return filePath;
103
- // if (path.sep !== '\\') return filePath;
104
- // return filePath.replace(/\\/g, '/');
105
- }
106
- exports.normalizePath = normalizePath;
107
- //# sourceMappingURL=fileEntryCache.js.map
@@ -1,4 +0,0 @@
1
- export type { CacheOptions } from './CacheOptions.js';
2
- export { calcCacheSettings, createCache, type CreateCacheSettings, DEFAULT_CACHE_LOCATION } from './createCache.js';
3
- export type { CSpellLintResultCache } from './CSpellLintResultCache.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CACHE_LOCATION = exports.createCache = exports.calcCacheSettings = void 0;
4
- var createCache_js_1 = require("./createCache.js");
5
- Object.defineProperty(exports, "calcCacheSettings", { enumerable: true, get: function () { return createCache_js_1.calcCacheSettings; } });
6
- Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_js_1.createCache; } });
7
- Object.defineProperty(exports, "DEFAULT_CACHE_LOCATION", { enumerable: true, get: function () { return createCache_js_1.DEFAULT_CACHE_LOCATION; } });
8
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- export declare const UTF8: BufferEncoding;
3
- export declare const STDIN = "stdin";
4
- export declare const STDINProtocol = "stdin://";
5
- export declare const FileProtocol = "file://";
6
- //# sourceMappingURL=constants.d.ts.map
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileProtocol = exports.STDINProtocol = exports.STDIN = exports.UTF8 = void 0;
4
- exports.UTF8 = 'utf8';
5
- exports.STDIN = 'stdin';
6
- exports.STDINProtocol = 'stdin://';
7
- exports.FileProtocol = 'file://';
8
- //# sourceMappingURL=constants.js.map
@@ -1,23 +0,0 @@
1
- export declare class CheckFailed extends Error {
2
- readonly exitCode: number;
3
- constructor(message: string, exitCode?: number);
4
- }
5
- export declare class ApplicationError extends Error {
6
- readonly exitCode: number;
7
- readonly cause?: Error | undefined;
8
- constructor(message: string, exitCode?: number, cause?: Error | undefined);
9
- }
10
- export declare class IOError extends ApplicationError {
11
- readonly cause: NodeError;
12
- constructor(message: string, cause: NodeError);
13
- get code(): string | undefined;
14
- isNotFound(): boolean;
15
- }
16
- export declare function toError(e: unknown): NodeError;
17
- export declare function isError(e: unknown): e is NodeError;
18
- export declare function toApplicationError(e: unknown, message?: string): ApplicationError;
19
- export interface NodeError extends Error {
20
- code?: string;
21
- toString?: () => string;
22
- }
23
- //# sourceMappingURL=errors.d.ts.map
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toApplicationError = exports.isError = exports.toError = exports.IOError = exports.ApplicationError = exports.CheckFailed = void 0;
4
- const util_1 = require("util");
5
- class CheckFailed extends Error {
6
- constructor(message, exitCode = 1) {
7
- super(message);
8
- this.exitCode = exitCode;
9
- }
10
- }
11
- exports.CheckFailed = CheckFailed;
12
- class ApplicationError extends Error {
13
- constructor(message, exitCode = 1, cause) {
14
- super(message);
15
- this.exitCode = exitCode;
16
- this.cause = cause;
17
- }
18
- }
19
- exports.ApplicationError = ApplicationError;
20
- class IOError extends ApplicationError {
21
- constructor(message, cause) {
22
- super(message, undefined, cause);
23
- this.cause = cause;
24
- }
25
- get code() {
26
- return this.cause.code;
27
- }
28
- isNotFound() {
29
- return this.cause.code === 'ENOENT';
30
- }
31
- }
32
- exports.IOError = IOError;
33
- function toError(e) {
34
- if (isError(e))
35
- return e;
36
- const message = (0, util_1.format)(e);
37
- return {
38
- name: 'error',
39
- message,
40
- toString: () => message,
41
- };
42
- }
43
- exports.toError = toError;
44
- function isError(e) {
45
- if (e instanceof Error)
46
- return true;
47
- if (!e || typeof e !== 'object')
48
- return false;
49
- const ex = e;
50
- return typeof ex.message === 'string';
51
- }
52
- exports.isError = isError;
53
- function toApplicationError(e, message) {
54
- if (e instanceof ApplicationError && !message)
55
- return e;
56
- const err = toError(e);
57
- return new ApplicationError(message ?? err.message, undefined, err);
58
- }
59
- exports.toApplicationError = toApplicationError;
60
- //# sourceMappingURL=errors.js.map
@@ -1,63 +0,0 @@
1
- /// <reference types="node" />
2
- import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
3
- import { URI } from '../../lib/uri.cjs';
4
- import type { GlobOptions } from './glob.js';
5
- export interface ConfigInfo {
6
- source: string;
7
- config: CSpellUserSettings;
8
- }
9
- export interface FileConfigInfo {
10
- configInfo: ConfigInfo;
11
- filename: string;
12
- text: string;
13
- languageIds: string[];
14
- }
15
- export declare function readConfig(configFile: string | undefined, root: string | undefined): Promise<ConfigInfo>;
16
- export interface FileInfo {
17
- filename: string;
18
- text?: string;
19
- errorCode?: string;
20
- }
21
- export interface FileResult {
22
- fileInfo: FileInfo;
23
- processed: boolean;
24
- issues: Issue[];
25
- errors: number;
26
- configErrors: number;
27
- elapsedTimeMs: number | undefined;
28
- cached?: boolean;
29
- }
30
- export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
31
- export declare function filenameToUrlString(filename: string, cwd?: string): string;
32
- export declare function filenameToUri(filename: string, cwd?: string): URI;
33
- export declare function isBinaryFile(filename: string, cwd?: string): boolean;
34
- export interface ReadFileInfoResult extends FileInfo {
35
- text: string;
36
- }
37
- export declare function resolveFilename(filename: string, cwd?: string): string;
38
- export declare function readFileInfo(filename: string, encoding?: BufferEncoding, handleNotFound?: boolean): Promise<ReadFileInfoResult>;
39
- export declare function readFile(filename: string, encoding?: BufferEncoding): Promise<string>;
40
- /**
41
- * Looks for matching glob patterns or stdin
42
- * @param globPatterns patterns or stdin
43
- */
44
- export declare function findFiles(globPatterns: string[], options: GlobOptions): Promise<string[]>;
45
- export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFromCommandLine: CSpellUserSettings, filename: string, text: string): FileConfigInfo;
46
- /**
47
- * Read
48
- * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
49
- * file will be resolved relative to the containing file.
50
- * @returns - a list of files to be processed.
51
- */
52
- export declare function readFileListFiles(listFiles: string[]): AsyncIterable<string>;
53
- /**
54
- * Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
55
- * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
56
- * file will be resolved relative to the containing file.
57
- * @returns - a list of files to be processed.
58
- */
59
- export declare function readFileListFile(listFile: string): Promise<string[]>;
60
- export declare function isFile(filename: string): Promise<boolean>;
61
- export declare function isDir(filename: string): Promise<boolean>;
62
- export declare function isNotDir(filename: string): Promise<boolean>;
63
- //# sourceMappingURL=fileHelper.d.ts.map