cspell 6.7.0 → 6.8.2
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/dist/application.d.ts +1 -1
- package/dist/application.js +10 -7
- package/dist/cli-reporter.js +2 -1
- package/dist/commandCheck.js +2 -0
- package/dist/commandLint.js +2 -0
- package/dist/lint/lint.js +2 -4
- package/dist/options.d.ts +4 -0
- package/dist/util/cache/CacheOptions.d.ts +8 -1
- package/dist/util/cache/DiskCache.d.ts +8 -3
- package/dist/util/cache/DiskCache.js +26 -9
- package/dist/util/cache/createCache.d.ts +5 -0
- package/dist/util/cache/createCache.js +14 -4
- package/dist/util/cache/fileEntryCache.d.ts +9 -0
- package/dist/util/cache/fileEntryCache.js +106 -0
- package/dist/util/fileHelper.js +1 -0
- package/dist/util/util.d.ts +1 -1
- package/package.json +12 -12
package/dist/application.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
|
-
import
|
|
3
|
+
import { CheckTextInfo, TraceResult } from 'cspell-lib';
|
|
4
4
|
import { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter';
|
|
5
5
|
import { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options';
|
|
6
6
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
package/dist/application.js
CHANGED
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.createInit = exports.suggestions = exports.checkText = exports.trace = exports.lint = exports.IncludeExcludeFlag = void 0;
|
|
27
27
|
const cspell_pipe_1 = require("@cspell/cspell-pipe");
|
|
28
28
|
const cspell_lib_1 = require("cspell-lib");
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
29
|
const cli_reporter_1 = require("./cli-reporter");
|
|
31
30
|
const lint_1 = require("./lint");
|
|
32
31
|
const options_1 = require("./options");
|
|
@@ -55,15 +54,19 @@ async function* trace(words, options) {
|
|
|
55
54
|
exports.trace = trace;
|
|
56
55
|
async function checkText(filename, options) {
|
|
57
56
|
options = (0, options_1.fixLegacy)(options);
|
|
58
|
-
const
|
|
59
|
-
const
|
|
57
|
+
const fileInfo = await (0, fileHelper_1.readFileInfo)(filename);
|
|
58
|
+
const { locale, languageId, validateDirectives } = options;
|
|
59
|
+
const doc = (0, fileHelper_1.fileInfoToDocument)(fileInfo, languageId, locale);
|
|
60
|
+
const checkOptions = {
|
|
61
|
+
configFile: options.config,
|
|
62
|
+
validateDirectives,
|
|
63
|
+
};
|
|
60
64
|
const settingsFromCommandLine = util.clean({
|
|
61
|
-
languageId
|
|
62
|
-
language:
|
|
65
|
+
languageId,
|
|
66
|
+
language: locale,
|
|
63
67
|
loadDefaultConfiguration: options.defaultConfiguration,
|
|
64
68
|
});
|
|
65
|
-
|
|
66
|
-
return (0, cspell_lib_1.checkText)(text, info.configInfo.config);
|
|
69
|
+
return (0, cspell_lib_1.checkTextDocument)(doc, checkOptions, settingsFromCommandLine);
|
|
67
70
|
}
|
|
68
71
|
exports.checkText = checkText;
|
|
69
72
|
async function* suggestions(words, options) {
|
package/dist/cli-reporter.js
CHANGED
|
@@ -164,7 +164,8 @@ function formatIssue(templateStr, issue, maxIssueTextWidth) {
|
|
|
164
164
|
const colText = col.toString();
|
|
165
165
|
const padRowCol = ' '.repeat(Math.max(1, 8 - (rowText.length + colText.length)));
|
|
166
166
|
const suggestions = issue.suggestions?.join(', ') || '';
|
|
167
|
-
const
|
|
167
|
+
const msg = issue.message || (issue.isFlagged ? 'Forbidden word' : 'Unknown word');
|
|
168
|
+
const message = issue.isFlagged ? `{yellow ${msg}}` : msg;
|
|
168
169
|
const substitutions = {
|
|
169
170
|
$col: colText,
|
|
170
171
|
$contextFull: contextFull,
|
package/dist/commandCheck.js
CHANGED
|
@@ -34,6 +34,8 @@ function commandCheck(prog) {
|
|
|
34
34
|
.command('check <files...>')
|
|
35
35
|
.description('Spell check file(s) and display the result. The full file is displayed in color.')
|
|
36
36
|
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
37
|
+
.option('--validate-directives', 'Validate in-document CSpell directives.')
|
|
38
|
+
.option('--no-validate-directives', 'Do not validate in-document CSpell directives.')
|
|
37
39
|
.option('--no-color', 'Turn off color.')
|
|
38
40
|
.option('--color', 'Force color')
|
|
39
41
|
.addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
package/dist/commandLint.js
CHANGED
|
@@ -90,6 +90,8 @@ function commandLint(prog) {
|
|
|
90
90
|
.option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.')
|
|
91
91
|
.option('--no-gitignore', 'Do NOT use .gitignore files.')
|
|
92
92
|
.option('--gitignore-root <path>', 'Prevent searching for .gitignore files past root.', collect)
|
|
93
|
+
.option('--validate-directives', 'Validate in-document CSpell directives.')
|
|
94
|
+
.option('--no-validate-directives', 'Do not validate in-document CSpell directives.')
|
|
93
95
|
.option('--no-color', 'Turn off color.')
|
|
94
96
|
.option('--color', 'Force color.')
|
|
95
97
|
.addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
package/dist/lint/lint.js
CHANGED
|
@@ -83,7 +83,8 @@ async function runLint(cfg) {
|
|
|
83
83
|
let spellResult = {};
|
|
84
84
|
reporter.info(`Checking: ${filename}, File type: ${doc.languageId ?? 'auto'}, Language: ${doc.locale ?? 'default'}`, cspell_types_1.MessageTypes.Info);
|
|
85
85
|
try {
|
|
86
|
-
const
|
|
86
|
+
const { showSuggestions: generateSuggestions, validateDirectives } = cfg.options;
|
|
87
|
+
const validateOptions = { generateSuggestions, numSuggestions: 5, validateDirectives };
|
|
87
88
|
const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config);
|
|
88
89
|
spellResult = r;
|
|
89
90
|
result.processed = r.checked;
|
|
@@ -125,9 +126,6 @@ async function runLint(cfg) {
|
|
|
125
126
|
const fileCount = files instanceof Array ? files.length : undefined;
|
|
126
127
|
const status = runResult();
|
|
127
128
|
const cache = (0, cache_1.createCache)(cacheSettings);
|
|
128
|
-
if (cfg.options.cacheReset) {
|
|
129
|
-
cache.reset();
|
|
130
|
-
}
|
|
131
129
|
const failFast = cfg.options.failFast ?? configInfo.config.failFast ?? false;
|
|
132
130
|
const emitProgressBegin = (filename, fileNum, fileCount) => reporter.progress({
|
|
133
131
|
type: 'ProgressFileBegin',
|
package/dist/options.d.ts
CHANGED
|
@@ -124,6 +124,10 @@ export interface BaseOptions {
|
|
|
124
124
|
* @default true
|
|
125
125
|
*/
|
|
126
126
|
defaultConfiguration?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Check In-Document CSpell directives for correctness.
|
|
129
|
+
*/
|
|
130
|
+
validateDirectives?: boolean;
|
|
127
131
|
}
|
|
128
132
|
export interface LinterCliOptions extends LinterOptions {
|
|
129
133
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheStrategy } from '@cspell/cspell-types';
|
|
1
|
+
import type { CacheStrategy, CacheFormat } from '@cspell/cspell-types';
|
|
2
2
|
export interface CacheOptions {
|
|
3
3
|
/**
|
|
4
4
|
* The version of `cspell` that made the cache entry.
|
|
@@ -23,5 +23,12 @@ export interface CacheOptions {
|
|
|
23
23
|
* Resets the cache
|
|
24
24
|
*/
|
|
25
25
|
cacheReset?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Format of the cache file.
|
|
28
|
+
* - `legacy` - use absolute paths in the cache file
|
|
29
|
+
* - `universal` - use a sharable format.
|
|
30
|
+
* @default 'legacy'
|
|
31
|
+
*/
|
|
32
|
+
cacheFormat?: CacheFormat;
|
|
26
33
|
}
|
|
27
34
|
//# sourceMappingURL=CacheOptions.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FileDescriptor } from 'file-entry-cache';
|
|
2
1
|
import type { FileResult } from '../../util/fileHelper';
|
|
3
2
|
import type { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
3
|
+
import { FileDescriptor } from './fileEntryCache';
|
|
4
4
|
export declare type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs' | 'cached'>;
|
|
5
5
|
/**
|
|
6
6
|
* This is the data cached.
|
|
@@ -31,15 +31,18 @@ export declare type CSpellCacheMeta = (Meta & CSpellCachedMetaData) | undefined;
|
|
|
31
31
|
export declare class DiskCache implements CSpellLintResultCache {
|
|
32
32
|
readonly useCheckSum: boolean;
|
|
33
33
|
readonly cspellVersion: string;
|
|
34
|
+
readonly useUniversalCache: boolean;
|
|
35
|
+
readonly cacheFileLocation: string;
|
|
36
|
+
private cacheDir;
|
|
34
37
|
private fileEntryCache;
|
|
35
38
|
private dependencyCache;
|
|
36
39
|
private dependencyCacheTree;
|
|
37
40
|
private objectCollection;
|
|
38
41
|
private ocCacheFileResult;
|
|
39
42
|
readonly version: string;
|
|
40
|
-
constructor(cacheFileLocation: string, useCheckSum: boolean, cspellVersion: string);
|
|
43
|
+
constructor(cacheFileLocation: string, useCheckSum: boolean, cspellVersion: string, useUniversalCache: boolean);
|
|
41
44
|
getCachedLintResults(filename: string): Promise<FileResult | undefined>;
|
|
42
|
-
setCachedLintResults({ fileInfo, elapsedTimeMs
|
|
45
|
+
setCachedLintResults({ fileInfo, elapsedTimeMs, cached, ...result }: FileResult, dependsUponFiles: string[]): void;
|
|
43
46
|
reconcile(): void;
|
|
44
47
|
reset(): void;
|
|
45
48
|
private normalizeResult;
|
|
@@ -49,6 +52,8 @@ export declare class DiskCache implements CSpellLintResultCache {
|
|
|
49
52
|
private getFileDep;
|
|
50
53
|
private checkDependencies;
|
|
51
54
|
private getHash;
|
|
55
|
+
private resolveFile;
|
|
56
|
+
private toRelFile;
|
|
52
57
|
}
|
|
53
58
|
declare function calcVersion(version: string): string;
|
|
54
59
|
export declare const __testing__: {
|
|
@@ -22,13 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.__testing__ = exports.DiskCache = void 0;
|
|
30
|
+
const assert_1 = __importDefault(require("assert"));
|
|
27
31
|
const crypto = __importStar(require("crypto"));
|
|
28
|
-
const fileEntryCache = __importStar(require("file-entry-cache"));
|
|
29
32
|
const fs = __importStar(require("fs"));
|
|
30
33
|
const path_1 = require("path");
|
|
31
34
|
const fileHelper_1 = require("../../util/fileHelper");
|
|
35
|
+
const fileEntryCache_1 = require("./fileEntryCache");
|
|
32
36
|
const ObjectCollection_1 = require("./ObjectCollection");
|
|
33
37
|
const cacheDataKeys = {
|
|
34
38
|
v: 'v',
|
|
@@ -45,17 +49,21 @@ const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.key
|
|
|
45
49
|
* Caches cspell results on disk
|
|
46
50
|
*/
|
|
47
51
|
class DiskCache {
|
|
48
|
-
constructor(cacheFileLocation, useCheckSum, cspellVersion) {
|
|
52
|
+
constructor(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
|
|
49
53
|
this.useCheckSum = useCheckSum;
|
|
50
54
|
this.cspellVersion = cspellVersion;
|
|
55
|
+
this.useUniversalCache = useUniversalCache;
|
|
51
56
|
this.dependencyCache = new Map();
|
|
52
57
|
this.dependencyCacheTree = {};
|
|
53
58
|
this.objectCollection = new ObjectCollection_1.ShallowObjectCollection();
|
|
54
59
|
this.ocCacheFileResult = new ObjectCollection_1.ShallowObjectCollection();
|
|
55
|
-
this.
|
|
60
|
+
this.cacheFileLocation = (0, path_1.resolve)(cacheFileLocation);
|
|
61
|
+
this.cacheDir = (0, path_1.dirname)(this.cacheFileLocation);
|
|
62
|
+
this.fileEntryCache = (0, fileEntryCache_1.createFromFile)(this.cacheFileLocation, useCheckSum, useUniversalCache);
|
|
56
63
|
this.version = calcVersion(cspellVersion);
|
|
57
64
|
}
|
|
58
65
|
async getCachedLintResults(filename) {
|
|
66
|
+
filename = (0, fileEntryCache_1.normalizePath)(filename);
|
|
59
67
|
const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename);
|
|
60
68
|
const meta = fileDescriptor.meta;
|
|
61
69
|
const data = meta?.data;
|
|
@@ -131,17 +139,18 @@ class DiskCache {
|
|
|
131
139
|
return setTreeEntry(this.dependencyCacheTree, dependencies);
|
|
132
140
|
}
|
|
133
141
|
checkDependency(dep) {
|
|
134
|
-
const
|
|
142
|
+
const depFile = this.resolveFile(dep.f);
|
|
143
|
+
const cDep = this.dependencyCache.get(depFile);
|
|
135
144
|
if (cDep && compDep(dep, cDep))
|
|
136
145
|
return true;
|
|
137
146
|
if (cDep)
|
|
138
147
|
return false;
|
|
139
|
-
const d = this.getFileDep(
|
|
148
|
+
const d = this.getFileDep(depFile);
|
|
140
149
|
if (compDep(dep, d)) {
|
|
141
|
-
this.dependencyCache.set(
|
|
150
|
+
this.dependencyCache.set(depFile, dep);
|
|
142
151
|
return true;
|
|
143
152
|
}
|
|
144
|
-
this.dependencyCache.set(
|
|
153
|
+
this.dependencyCache.set(depFile, d);
|
|
145
154
|
return false;
|
|
146
155
|
}
|
|
147
156
|
getDependency(file) {
|
|
@@ -153,15 +162,17 @@ class DiskCache {
|
|
|
153
162
|
return d;
|
|
154
163
|
}
|
|
155
164
|
getFileDep(file) {
|
|
165
|
+
(0, assert_1.default)((0, path_1.isAbsolute)(file));
|
|
166
|
+
const f = this.toRelFile(file);
|
|
156
167
|
let h;
|
|
157
168
|
try {
|
|
158
169
|
const buffer = fs.readFileSync(file);
|
|
159
170
|
h = this.getHash(buffer);
|
|
160
171
|
}
|
|
161
172
|
catch (e) {
|
|
162
|
-
return { f
|
|
173
|
+
return { f };
|
|
163
174
|
}
|
|
164
|
-
return { f
|
|
175
|
+
return { f, h };
|
|
165
176
|
}
|
|
166
177
|
checkDependencies(dependencies) {
|
|
167
178
|
if (!dependencies)
|
|
@@ -176,6 +187,12 @@ class DiskCache {
|
|
|
176
187
|
getHash(buffer) {
|
|
177
188
|
return crypto.createHash('md5').update(buffer).digest('hex');
|
|
178
189
|
}
|
|
190
|
+
resolveFile(file) {
|
|
191
|
+
return (0, fileEntryCache_1.normalizePath)((0, path_1.resolve)(this.cacheDir, file));
|
|
192
|
+
}
|
|
193
|
+
toRelFile(file) {
|
|
194
|
+
return (0, fileEntryCache_1.normalizePath)(this.useUniversalCache ? (0, path_1.relative)(this.cacheDir, file) : file);
|
|
195
|
+
}
|
|
179
196
|
}
|
|
180
197
|
exports.DiskCache = DiskCache;
|
|
181
198
|
function getTreeEntry(tree, keys) {
|
|
@@ -7,6 +7,11 @@ export interface CreateCacheSettings extends Required<CacheSettings> {
|
|
|
7
7
|
* cspell version used to validate cache entries.
|
|
8
8
|
*/
|
|
9
9
|
version: string;
|
|
10
|
+
/**
|
|
11
|
+
* When true, causes the cache to be reset, removing any entries
|
|
12
|
+
* or cache files.
|
|
13
|
+
*/
|
|
14
|
+
reset?: true;
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
@@ -17,10 +17,14 @@ const versionSuffix = '';
|
|
|
17
17
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
18
18
|
*/
|
|
19
19
|
function createCache(options) {
|
|
20
|
-
const { useCache, cacheLocation, cacheStrategy } = options;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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_1.DiskCache(location, useChecksum, version, useUniversal) : new DummyCache_1.DummyCache();
|
|
26
|
+
reset && cache.reset();
|
|
27
|
+
return cache;
|
|
24
28
|
}
|
|
25
29
|
exports.createCache = createCache;
|
|
26
30
|
async function calcCacheSettings(config, cacheOptions, root) {
|
|
@@ -28,11 +32,17 @@ async function calcCacheSettings(config, cacheOptions, root) {
|
|
|
28
32
|
const useCache = cacheOptions.cache ?? cs.useCache ?? false;
|
|
29
33
|
const cacheLocation = await resolveCacheLocation(path_1.default.resolve(root, cacheOptions.cacheLocation ?? cs.cacheLocation ?? exports.DEFAULT_CACHE_LOCATION));
|
|
30
34
|
const cacheStrategy = cacheOptions.cacheStrategy ?? cs.cacheStrategy ?? 'metadata';
|
|
35
|
+
const optionals = {};
|
|
36
|
+
if (cacheOptions.cacheReset) {
|
|
37
|
+
optionals.reset = true;
|
|
38
|
+
}
|
|
31
39
|
return {
|
|
40
|
+
...optionals,
|
|
32
41
|
useCache,
|
|
33
42
|
cacheLocation,
|
|
34
43
|
cacheStrategy,
|
|
35
44
|
version: cacheOptions.version,
|
|
45
|
+
cacheFormat: cacheOptions.cacheFormat || 'legacy',
|
|
36
46
|
};
|
|
37
47
|
}
|
|
38
48
|
exports.calcCacheSettings = calcCacheSettings;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a wrapper for 'file-entry-cache'
|
|
3
|
+
*/
|
|
4
|
+
export type { FileDescriptor } from 'file-entry-cache';
|
|
5
|
+
import type { FileEntryCache as FecFileEntryCache } from 'file-entry-cache';
|
|
6
|
+
export declare 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
|
|
@@ -0,0 +1,106 @@
|
|
|
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 file_entry_cache = __importStar(require("file-entry-cache"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const fs = __importStar(require("fs-extra"));
|
|
33
|
+
function createFromFile(pathToCache, useCheckSum, useRelative) {
|
|
34
|
+
const absPathToCache = path.resolve(pathToCache);
|
|
35
|
+
const relDir = path.dirname(absPathToCache);
|
|
36
|
+
fs.mkdirpSync(relDir);
|
|
37
|
+
const create = wrap(() => file_entry_cache.createFromFile(absPathToCache, useCheckSum));
|
|
38
|
+
const feCache = create();
|
|
39
|
+
const cacheWrapper = {
|
|
40
|
+
get cache() {
|
|
41
|
+
return feCache.cache;
|
|
42
|
+
},
|
|
43
|
+
getHash(buffer) {
|
|
44
|
+
return feCache.getHash(buffer);
|
|
45
|
+
},
|
|
46
|
+
hasFileChanged: wrap((cwd, file) => {
|
|
47
|
+
console.log(file);
|
|
48
|
+
return feCache.hasFileChanged(resolveFile(cwd, file));
|
|
49
|
+
}),
|
|
50
|
+
analyzeFiles: wrap((cwd, files) => {
|
|
51
|
+
return feCache.analyzeFiles(resolveFiles(cwd, files));
|
|
52
|
+
}),
|
|
53
|
+
getFileDescriptor: wrap((cwd, file) => {
|
|
54
|
+
return feCache.getFileDescriptor(resolveFile(cwd, file));
|
|
55
|
+
}),
|
|
56
|
+
getUpdatedFiles: wrap((cwd, files) => {
|
|
57
|
+
return feCache.getUpdatedFiles(resolveFiles(cwd, files));
|
|
58
|
+
}),
|
|
59
|
+
normalizeEntries: wrap((cwd, files) => {
|
|
60
|
+
return feCache.normalizeEntries(resolveFiles(cwd, files));
|
|
61
|
+
}),
|
|
62
|
+
removeEntry: wrap((cwd, file) => {
|
|
63
|
+
console.log(file);
|
|
64
|
+
return feCache.removeEntry(resolveFile(cwd, file));
|
|
65
|
+
}),
|
|
66
|
+
deleteCacheFile() {
|
|
67
|
+
feCache.deleteCacheFile();
|
|
68
|
+
},
|
|
69
|
+
destroy() {
|
|
70
|
+
feCache.destroy();
|
|
71
|
+
},
|
|
72
|
+
reconcile: wrap((_cwd, noPrune) => {
|
|
73
|
+
feCache.reconcile(noPrune);
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
return cacheWrapper;
|
|
77
|
+
function resolveFile(cwd, file) {
|
|
78
|
+
if (!useRelative)
|
|
79
|
+
return file;
|
|
80
|
+
const r = path.relative(relDir, path.resolve(cwd, file));
|
|
81
|
+
return normalizePath(r);
|
|
82
|
+
}
|
|
83
|
+
function resolveFiles(cwd, files) {
|
|
84
|
+
return files?.map((file) => resolveFile(cwd, file));
|
|
85
|
+
}
|
|
86
|
+
function wrap(fn) {
|
|
87
|
+
return (...params) => {
|
|
88
|
+
const cwd = process.cwd();
|
|
89
|
+
try {
|
|
90
|
+
process.chdir(relDir);
|
|
91
|
+
return fn(cwd, ...params);
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
process.chdir(cwd);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.createFromFile = createFromFile;
|
|
100
|
+
function normalizePath(filePath) {
|
|
101
|
+
return filePath;
|
|
102
|
+
// if (path.sep !== '\\') return filePath;
|
|
103
|
+
// return filePath.replace(/\\/g, '/');
|
|
104
|
+
}
|
|
105
|
+
exports.normalizePath = normalizePath;
|
|
106
|
+
//# sourceMappingURL=fileEntryCache.js.map
|
package/dist/util/fileHelper.js
CHANGED
|
@@ -63,6 +63,7 @@ function fileInfoToDocument(fileInfo, languageId, locale) {
|
|
|
63
63
|
}
|
|
64
64
|
exports.fileInfoToDocument = fileInfoToDocument;
|
|
65
65
|
function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
|
|
66
|
+
filename = filename !== STDIN ? path.resolve(filename) : filename;
|
|
66
67
|
const pText = filename === STDIN ? (0, get_stdin_1.default)() : fs_1.promises.readFile(filename, encoding);
|
|
67
68
|
return pText.then((text) => ({ text, filename }), (e) => {
|
|
68
69
|
const error = (0, errors_1.toError)(e);
|
package/dist/util/util.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ declare type FilterFn<T> = (_v: T) => boolean;
|
|
|
3
3
|
export declare function uniqueFilterFnGenerator<T>(): FilterFn<T>;
|
|
4
4
|
export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): FilterFn<T>;
|
|
5
5
|
export declare function unique<T>(src: T[]): T[];
|
|
6
|
-
export declare function clean<T>(src: T): T;
|
|
6
|
+
export declare function clean<T extends object>(src: T): T;
|
|
7
7
|
export declare function padWidth(s: string, target: number): number;
|
|
8
8
|
export declare function pad(s: string, w: number): string;
|
|
9
9
|
export declare function padLeft(s: string, w: number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.2",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@cspell/cspell-pipe": "^6.
|
|
73
|
+
"@cspell/cspell-pipe": "^6.8.2",
|
|
74
74
|
"chalk": "^4.1.2",
|
|
75
75
|
"commander": "^9.4.0",
|
|
76
|
-
"cspell-gitignore": "^6.
|
|
77
|
-
"cspell-glob": "^6.
|
|
78
|
-
"cspell-lib": "^6.
|
|
76
|
+
"cspell-gitignore": "^6.8.2",
|
|
77
|
+
"cspell-glob": "^6.8.2",
|
|
78
|
+
"cspell-lib": "^6.8.2",
|
|
79
79
|
"fast-json-stable-stringify": "^2.1.0",
|
|
80
80
|
"file-entry-cache": "^6.0.1",
|
|
81
81
|
"fs-extra": "^10.1.0",
|
|
@@ -90,21 +90,21 @@
|
|
|
90
90
|
"node": ">=14"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@cspell/cspell-json-reporter": "^6.
|
|
94
|
-
"@cspell/cspell-types": "^6.
|
|
93
|
+
"@cspell/cspell-json-reporter": "^6.8.2",
|
|
94
|
+
"@cspell/cspell-types": "^6.8.2",
|
|
95
95
|
"@types/file-entry-cache": "^5.0.2",
|
|
96
96
|
"@types/fs-extra": "^9.0.13",
|
|
97
|
-
"@types/glob": "^
|
|
97
|
+
"@types/glob": "^8.0.0",
|
|
98
98
|
"@types/imurmurhash": "^0.1.1",
|
|
99
99
|
"@types/micromatch": "^4.0.2",
|
|
100
|
-
"@types/minimatch": "^
|
|
100
|
+
"@types/minimatch": "^5.1.2",
|
|
101
101
|
"@types/semver": "^7.3.12",
|
|
102
|
-
"jest": "^
|
|
102
|
+
"jest": "^29.0.3",
|
|
103
103
|
"micromatch": "^4.0.5",
|
|
104
104
|
"minimatch": "^5.1.0",
|
|
105
105
|
"rimraf": "^3.0.2",
|
|
106
|
-
"rollup": "^2.
|
|
106
|
+
"rollup": "^2.79.0",
|
|
107
107
|
"rollup-plugin-dts": "^4.2.2"
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "fb47a5f2f93d333fe5540142f3217e4981a7c27d"
|
|
110
110
|
}
|