cspell 5.14.0-alpha.0 → 5.15.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/README.md +8 -2
- package/dist/commandLint.js +3 -2
- package/dist/lint/lint.js +15 -12
- package/dist/options.d.ts +12 -0
- package/dist/util/cache/CSpellLintResultCache.d.ts +3 -3
- package/dist/util/cache/CacheOptions.d.ts +2 -1
- package/dist/util/cache/DiskCache.d.ts +24 -3
- package/dist/util/cache/DiskCache.js +56 -14
- package/dist/util/cache/createCache.d.ts +5 -5
- package/dist/util/cache/createCache.js +32 -3
- package/dist/util/cache/index.d.ts +1 -2
- package/dist/util/cache/index.js +2 -1
- package/dist/util/errors.d.ts +5 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -56,6 +56,12 @@ cspell lint "src/**/*.js"
|
|
|
56
56
|
cspell "**"
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
**Git: Check Only Changed Files**
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
git diff --name-only | npx cspell --file-list stdin
|
|
63
|
+
```
|
|
64
|
+
|
|
59
65
|
## Command: `lint` -- Spell Checking
|
|
60
66
|
|
|
61
67
|
The `lint` command is used for spell checking files.
|
|
@@ -110,8 +116,8 @@ Options:
|
|
|
110
116
|
--show-suggestions Show spelling suggestions.
|
|
111
117
|
--no-must-find-files Do not error if no files are found.
|
|
112
118
|
|
|
113
|
-
--cache
|
|
114
|
-
|
|
119
|
+
--cache Use cache to only check changed files.
|
|
120
|
+
--no-cache Do not use cache.
|
|
115
121
|
--cache-strategy <strategy> Strategy to use for detecting changed files.
|
|
116
122
|
(choices: "metadata", "content")
|
|
117
123
|
|
package/dist/commandLint.js
CHANGED
|
@@ -73,12 +73,13 @@ function commandLint(prog) {
|
|
|
73
73
|
// .option('--force', 'Force the exit value to always be 0')
|
|
74
74
|
.addOption(new commander_1.Option('--legacy', 'Legacy output').hideHelp())
|
|
75
75
|
.addOption(new commander_1.Option('--local <local>', 'Deprecated -- Use: --locale').hideHelp())
|
|
76
|
-
.option('--cache', '
|
|
76
|
+
.option('--cache', 'Use cache to only check changed files.')
|
|
77
|
+
.option('--no-cache', 'Do not use cache.')
|
|
77
78
|
.addOption(new commander_1.Option('--cache-strategy <strategy>', 'Strategy to use for detecting changed files.').choices([
|
|
78
79
|
'metadata',
|
|
79
80
|
'content',
|
|
80
81
|
]))
|
|
81
|
-
.option('--cache-location <path>', `Path to the cache file or directory
|
|
82
|
+
.option('--cache-location <path>', `Path to the cache file or directory. (default: "${cache_1.DEFAULT_CACHE_LOCATION}")`)
|
|
82
83
|
.option('--dot', 'Include files and directories starting with `.` (period) when matching globs.')
|
|
83
84
|
.option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.')
|
|
84
85
|
.option('--no-gitignore', 'Do NOT use .gitignore files.')
|
package/dist/lint/lint.js
CHANGED
|
@@ -45,7 +45,7 @@ async function runLint(cfg) {
|
|
|
45
45
|
return lintResult;
|
|
46
46
|
async function processFile(filename, configInfo, cache) {
|
|
47
47
|
var _a, _b, _c, _d;
|
|
48
|
-
const cachedResult = await cache.getCachedLintResults(filename
|
|
48
|
+
const cachedResult = await cache.getCachedLintResults(filename);
|
|
49
49
|
if (cachedResult) {
|
|
50
50
|
reporter.debug(`Filename: ${filename}, using cache`);
|
|
51
51
|
return cachedResult;
|
|
@@ -86,7 +86,8 @@ async function runLint(cfg) {
|
|
|
86
86
|
reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`, cspell_types_1.MessageTypes.Info);
|
|
87
87
|
reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, cspell_types_1.MessageTypes.Info);
|
|
88
88
|
reporter.info(`Dictionaries Used: ${dictionaries.join(', ')}`, cspell_types_1.MessageTypes.Info);
|
|
89
|
-
|
|
89
|
+
const dep = calcDependencies(config);
|
|
90
|
+
cache.setCachedLintResults(result, dep.files);
|
|
90
91
|
return result;
|
|
91
92
|
}
|
|
92
93
|
function mapIssue({ doc: _, ...tdo }) {
|
|
@@ -95,9 +96,10 @@ async function runLint(cfg) {
|
|
|
95
96
|
: { text: tdo.line.text.trimEnd(), offset: tdo.line.offset };
|
|
96
97
|
return { ...tdo, context };
|
|
97
98
|
}
|
|
98
|
-
async function processFiles(files, configInfo,
|
|
99
|
+
async function processFiles(files, configInfo, cacheSettings) {
|
|
100
|
+
const fileCount = files.length;
|
|
99
101
|
const status = runResult();
|
|
100
|
-
const cache = (0, cache_1.createCache)(
|
|
102
|
+
const cache = (0, cache_1.createCache)(cacheSettings);
|
|
101
103
|
const emitProgress = (filename, fileNum, result) => reporter.progress({
|
|
102
104
|
type: 'ProgressFileComplete',
|
|
103
105
|
fileNum,
|
|
@@ -117,12 +119,8 @@ async function runLint(cfg) {
|
|
|
117
119
|
}
|
|
118
120
|
for await (const fileP of loadAndProcessFiles()) {
|
|
119
121
|
const { filename, fileNum, result } = await fileP;
|
|
120
|
-
if (!result.fileInfo.text === undefined) {
|
|
121
|
-
status.files += result.cached ? 1 : 0;
|
|
122
|
-
emitProgress(filename, fileNum, result);
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
122
|
status.files += 1;
|
|
123
|
+
status.cachedFiles = (status.cachedFiles || 0) + (result.cached ? 1 : 0);
|
|
126
124
|
emitProgress(filename, fileNum, result);
|
|
127
125
|
// Show the spelling errors after emitting the progress.
|
|
128
126
|
result.issues.filter(cfg.uniqueFilter).forEach((issue) => reporter.issue(issue));
|
|
@@ -136,6 +134,10 @@ async function runLint(cfg) {
|
|
|
136
134
|
cache.reconcile();
|
|
137
135
|
return status;
|
|
138
136
|
}
|
|
137
|
+
function calcDependencies(config) {
|
|
138
|
+
const { configFiles, dictionaryFiles } = cspell.extractDependencies(config);
|
|
139
|
+
return { files: configFiles.concat(dictionaryFiles) };
|
|
140
|
+
}
|
|
139
141
|
async function reportConfigurationErrors(config) {
|
|
140
142
|
const errors = cspell.extractImportErrors(config);
|
|
141
143
|
let count = 0;
|
|
@@ -212,12 +214,13 @@ async function runLint(cfg) {
|
|
|
212
214
|
globOptions.dot = enableGlobDot;
|
|
213
215
|
}
|
|
214
216
|
try {
|
|
217
|
+
const cacheSettings = await (0, cache_1.calcCacheSettings)(configInfo.config, cfg.options, root);
|
|
215
218
|
const foundFiles = await (hasFileLists
|
|
216
219
|
? useFileLists(fileLists, allGlobs, root, enableGlobDot)
|
|
217
220
|
: (0, fileHelper_1.findFiles)(fileGlobs, globOptions));
|
|
218
221
|
const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles;
|
|
219
222
|
const files = filterFiles(filtered, globMatcher);
|
|
220
|
-
return await processFiles(files, configInfo,
|
|
223
|
+
return await processFiles(files, configInfo, cacheSettings);
|
|
221
224
|
}
|
|
222
225
|
catch (e) {
|
|
223
226
|
const err = (0, errors_1.toApplicationError)(e);
|
|
@@ -300,8 +303,8 @@ function extractContext(tdo, contextRange) {
|
|
|
300
303
|
return context;
|
|
301
304
|
}
|
|
302
305
|
function runResult(init = {}) {
|
|
303
|
-
const { files = 0, filesWithIssues = new Set(), issues = 0, errors = 0 } = init;
|
|
304
|
-
return { files, filesWithIssues, issues, errors };
|
|
306
|
+
const { files = 0, filesWithIssues = new Set(), issues = 0, errors = 0, cachedFiles = 0 } = init;
|
|
307
|
+
return { files, filesWithIssues, issues, errors, cachedFiles };
|
|
305
308
|
}
|
|
306
309
|
function yesNo(value) {
|
|
307
310
|
return value ? 'Yes' : 'No';
|
package/dist/options.d.ts
CHANGED
|
@@ -60,9 +60,21 @@ export interface TraceOptions extends BaseOptions {
|
|
|
60
60
|
ignoreCase?: boolean;
|
|
61
61
|
}
|
|
62
62
|
export interface BaseOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Path to configuration file.
|
|
65
|
+
*/
|
|
63
66
|
config?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Programming Language ID.
|
|
69
|
+
*/
|
|
64
70
|
languageId?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Locale to use.
|
|
73
|
+
*/
|
|
65
74
|
locale?: string;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated
|
|
77
|
+
*/
|
|
66
78
|
local?: string;
|
|
67
79
|
}
|
|
68
80
|
export interface LinterCliOptions extends Omit<LinterOptions, 'fileLists'> {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileResult } from '../../fileHelper';
|
|
2
2
|
export interface CSpellLintResultCache {
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve cached lint results for a given file name, if present in the cache.
|
|
5
5
|
*/
|
|
6
|
-
getCachedLintResults(filename: string
|
|
6
|
+
getCachedLintResults(filename: string): Promise<FileResult | undefined>;
|
|
7
7
|
/**
|
|
8
8
|
* Set the cached lint results.
|
|
9
9
|
*/
|
|
10
|
-
setCachedLintResults(result: FileResult,
|
|
10
|
+
setCachedLintResults(result: FileResult, dependsUponFiles: string[]): void;
|
|
11
11
|
/**
|
|
12
12
|
* Persists the in-memory cache to disk.
|
|
13
13
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheStrategy } from '@cspell/cspell-types';
|
|
1
2
|
export interface CacheOptions {
|
|
2
3
|
/**
|
|
3
4
|
* Store the info about processed files in order to only operate on the changed ones.
|
|
@@ -12,6 +13,6 @@ export interface CacheOptions {
|
|
|
12
13
|
/**
|
|
13
14
|
* Strategy to use for detecting changed files, default: metadata
|
|
14
15
|
*/
|
|
15
|
-
cacheStrategy?:
|
|
16
|
+
cacheStrategy?: CacheStrategy;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=CacheOptions.d.ts.map
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileDescriptor } from 'file-entry-cache';
|
|
2
|
+
import type { FileResult } from '../../fileHelper';
|
|
2
3
|
import type { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
4
|
+
export declare type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs'>;
|
|
5
|
+
/**
|
|
6
|
+
* This is the data cached.
|
|
7
|
+
* Property names are short to help keep the cache file size small.
|
|
8
|
+
*/
|
|
9
|
+
interface CachedData {
|
|
10
|
+
/** results */
|
|
11
|
+
r: CachedFileResult;
|
|
12
|
+
/** dependencies */
|
|
13
|
+
d: string[];
|
|
14
|
+
}
|
|
15
|
+
interface CSpellCachedMetaData {
|
|
16
|
+
data?: CachedData;
|
|
17
|
+
}
|
|
18
|
+
export declare type CSpellCacheMeta = (FileDescriptor['meta'] & CSpellCachedMetaData) | undefined;
|
|
3
19
|
/**
|
|
4
20
|
* Caches cspell results on disk
|
|
5
21
|
*/
|
|
6
22
|
export declare class DiskCache implements CSpellLintResultCache {
|
|
7
23
|
private fileEntryCache;
|
|
24
|
+
private changedDependencies;
|
|
25
|
+
private knownDependencies;
|
|
8
26
|
constructor(cacheFileLocation: string, useCheckSum: boolean);
|
|
9
|
-
getCachedLintResults(filename: string
|
|
10
|
-
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }: FileResult,
|
|
27
|
+
getCachedLintResults(filename: string): Promise<FileResult | undefined>;
|
|
28
|
+
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }: FileResult, dependsUponFiles: string[]): void;
|
|
11
29
|
reconcile(): void;
|
|
30
|
+
private cacheDependencies;
|
|
31
|
+
private checkDependencies;
|
|
12
32
|
}
|
|
33
|
+
export {};
|
|
13
34
|
//# sourceMappingURL=DiskCache.d.ts.map
|
|
@@ -1,53 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.DiskCache = void 0;
|
|
4
|
-
const
|
|
23
|
+
const fileEntryCache = __importStar(require("file-entry-cache"));
|
|
24
|
+
const path_1 = require("path");
|
|
5
25
|
const fileHelper_1 = require("../../fileHelper");
|
|
6
|
-
const getConfigHash_1 = require("./getConfigHash");
|
|
7
26
|
/**
|
|
8
27
|
* Caches cspell results on disk
|
|
9
28
|
*/
|
|
10
29
|
class DiskCache {
|
|
11
30
|
constructor(cacheFileLocation, useCheckSum) {
|
|
12
|
-
this.
|
|
31
|
+
this.changedDependencies = new Set();
|
|
32
|
+
this.knownDependencies = new Set();
|
|
33
|
+
this.fileEntryCache = fileEntryCache.createFromFile((0, path_1.resolve)(cacheFileLocation), useCheckSum);
|
|
13
34
|
}
|
|
14
|
-
async getCachedLintResults(filename
|
|
35
|
+
async getCachedLintResults(filename) {
|
|
15
36
|
const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename);
|
|
16
37
|
const meta = fileDescriptor.meta;
|
|
38
|
+
const data = meta === null || meta === void 0 ? void 0 : meta.data;
|
|
39
|
+
const result = data === null || data === void 0 ? void 0 : data.r;
|
|
17
40
|
// Cached lint results are valid if and only if:
|
|
18
41
|
// 1. The file is present in the filesystem
|
|
19
42
|
// 2. The file has not changed since the time it was previously linted
|
|
20
43
|
// 3. The CSpell configuration has not changed since the time the file was previously linted
|
|
21
44
|
// If any of these are not true, we will not reuse the lint results.
|
|
22
|
-
if (fileDescriptor.notFound ||
|
|
23
|
-
fileDescriptor.changed ||
|
|
24
|
-
!meta ||
|
|
25
|
-
meta.configHash !== (0, getConfigHash_1.getConfigHash)(configInfo)) {
|
|
45
|
+
if (fileDescriptor.notFound || fileDescriptor.changed || !meta || !result || !this.checkDependencies(data.d)) {
|
|
26
46
|
return undefined;
|
|
27
47
|
}
|
|
28
48
|
// Skip reading empty files and files without lint error
|
|
29
|
-
const hasErrors =
|
|
30
|
-
const cached =
|
|
49
|
+
const hasErrors = !!result && (result.errors > 0 || result.configErrors > 0 || result.issues.length > 0);
|
|
50
|
+
const cached = true;
|
|
31
51
|
const shouldReadFile = cached && hasErrors;
|
|
32
52
|
return {
|
|
33
|
-
...
|
|
53
|
+
...result,
|
|
34
54
|
elapsedTimeMs: undefined,
|
|
35
55
|
fileInfo: shouldReadFile ? await (0, fileHelper_1.readFileInfo)(filename) : { filename },
|
|
36
56
|
cached,
|
|
37
57
|
};
|
|
38
58
|
}
|
|
39
|
-
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result },
|
|
59
|
+
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }, dependsUponFiles) {
|
|
40
60
|
const fileDescriptor = this.fileEntryCache.getFileDescriptor(fileInfo.filename);
|
|
41
61
|
const meta = fileDescriptor.meta;
|
|
42
62
|
if (fileDescriptor.notFound || !meta) {
|
|
43
63
|
return;
|
|
44
64
|
}
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
const data = {
|
|
66
|
+
r: result,
|
|
67
|
+
d: dependsUponFiles,
|
|
68
|
+
};
|
|
69
|
+
meta.data = data;
|
|
70
|
+
this.cacheDependencies(dependsUponFiles);
|
|
47
71
|
}
|
|
48
72
|
reconcile() {
|
|
49
73
|
this.fileEntryCache.reconcile();
|
|
50
74
|
}
|
|
75
|
+
cacheDependencies(files) {
|
|
76
|
+
this.fileEntryCache.analyzeFiles(files);
|
|
77
|
+
}
|
|
78
|
+
checkDependencies(files) {
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
if (this.changedDependencies.has(file)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const unknown = files.filter((f) => !this.knownDependencies.has(f));
|
|
85
|
+
if (!unknown.length) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const { changedFiles, notFoundFiles } = this.fileEntryCache.analyzeFiles(files);
|
|
89
|
+
changedFiles.map((f) => this.changedDependencies.add(f));
|
|
90
|
+
unknown.forEach((f) => this.knownDependencies.add(f));
|
|
91
|
+
return changedFiles.length === 0 && notFoundFiles.length === 0;
|
|
92
|
+
}
|
|
51
93
|
}
|
|
52
94
|
exports.DiskCache = DiskCache;
|
|
53
95
|
//# sourceMappingURL=DiskCache.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
|
|
2
|
+
import { CacheOptions } from '.';
|
|
2
3
|
import { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
3
4
|
export declare const DEFAULT_CACHE_LOCATION = ".cspellcache";
|
|
4
|
-
export
|
|
5
|
-
root: string;
|
|
6
|
-
}
|
|
5
|
+
export declare type CreateCacheSettings = Required<CacheSettings>;
|
|
7
6
|
/**
|
|
8
7
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
9
8
|
*/
|
|
10
|
-
export declare function createCache(options:
|
|
9
|
+
export declare function createCache(options: CreateCacheSettings): CSpellLintResultCache;
|
|
10
|
+
export declare function calcCacheSettings(config: CSpellSettings, cacheOptions: CacheOptions, root: string): Promise<CreateCacheSettings>;
|
|
11
11
|
//# sourceMappingURL=createCache.d.ts.map
|
|
@@ -3,18 +3,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createCache = exports.DEFAULT_CACHE_LOCATION = void 0;
|
|
6
|
+
exports.calcCacheSettings = exports.createCache = exports.DEFAULT_CACHE_LOCATION = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const DiskCache_1 = require("./DiskCache");
|
|
9
9
|
const DummyCache_1 = require("./DummyCache");
|
|
10
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
const errors_1 = require("../errors");
|
|
10
12
|
// cspell:word cspellcache
|
|
11
13
|
exports.DEFAULT_CACHE_LOCATION = '.cspellcache';
|
|
12
14
|
/**
|
|
13
15
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
14
16
|
*/
|
|
15
17
|
function createCache(options) {
|
|
16
|
-
const {
|
|
17
|
-
return
|
|
18
|
+
const { useCache, cacheLocation, cacheStrategy } = options;
|
|
19
|
+
return useCache ? new DiskCache_1.DiskCache(path_1.default.resolve(cacheLocation), cacheStrategy === 'content') : new DummyCache_1.DummyCache();
|
|
18
20
|
}
|
|
19
21
|
exports.createCache = createCache;
|
|
22
|
+
async function calcCacheSettings(config, cacheOptions, root) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
24
|
+
const cs = (_a = config.cache) !== null && _a !== void 0 ? _a : {};
|
|
25
|
+
const useCache = (_c = (_b = cacheOptions.cache) !== null && _b !== void 0 ? _b : cs.useCache) !== null && _c !== void 0 ? _c : false;
|
|
26
|
+
const cacheLocation = await resolveCacheLocation(path_1.default.resolve(root, (_e = (_d = cacheOptions.cacheLocation) !== null && _d !== void 0 ? _d : cs.cacheLocation) !== null && _e !== void 0 ? _e : exports.DEFAULT_CACHE_LOCATION));
|
|
27
|
+
const cacheStrategy = (_g = (_f = cacheOptions.cacheStrategy) !== null && _f !== void 0 ? _f : cs.cacheStrategy) !== null && _g !== void 0 ? _g : 'metadata';
|
|
28
|
+
return {
|
|
29
|
+
useCache,
|
|
30
|
+
cacheLocation,
|
|
31
|
+
cacheStrategy,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.calcCacheSettings = calcCacheSettings;
|
|
35
|
+
async function resolveCacheLocation(cacheLocation) {
|
|
36
|
+
try {
|
|
37
|
+
const s = await (0, fs_extra_1.stat)(cacheLocation);
|
|
38
|
+
if (s.isFile())
|
|
39
|
+
return cacheLocation;
|
|
40
|
+
return path_1.default.join(cacheLocation, exports.DEFAULT_CACHE_LOCATION);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
if ((0, errors_1.isError)(err) && err.code === 'ENOENT') {
|
|
44
|
+
return cacheLocation;
|
|
45
|
+
}
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
20
49
|
//# sourceMappingURL=createCache.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { createCache, DEFAULT_CACHE_LOCATION } from './createCache';
|
|
2
|
-
export type { CreateCacheOptions } from './createCache';
|
|
1
|
+
export { createCache, calcCacheSettings, DEFAULT_CACHE_LOCATION, type CreateCacheSettings } from './createCache';
|
|
3
2
|
export type { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
4
3
|
export type { CacheOptions } from './CacheOptions';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/util/cache/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_CACHE_LOCATION = exports.createCache = void 0;
|
|
3
|
+
exports.DEFAULT_CACHE_LOCATION = exports.calcCacheSettings = exports.createCache = void 0;
|
|
4
4
|
var createCache_1 = require("./createCache");
|
|
5
5
|
Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_1.createCache; } });
|
|
6
|
+
Object.defineProperty(exports, "calcCacheSettings", { enumerable: true, get: function () { return createCache_1.calcCacheSettings; } });
|
|
6
7
|
Object.defineProperty(exports, "DEFAULT_CACHE_LOCATION", { enumerable: true, get: function () { return createCache_1.DEFAULT_CACHE_LOCATION; } });
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/util/errors.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export declare class ApplicationError extends Error {
|
|
|
8
8
|
constructor(message: string, exitCode?: number, cause?: Error | undefined);
|
|
9
9
|
}
|
|
10
10
|
export declare function toError(e: unknown): Error;
|
|
11
|
-
export declare function isError(e: unknown): e is
|
|
11
|
+
export declare function isError(e: unknown): e is NodeError;
|
|
12
12
|
export declare function toApplicationError(e: unknown, message?: string): ApplicationError;
|
|
13
|
+
interface NodeError extends Error {
|
|
14
|
+
code?: string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
13
17
|
//# sourceMappingURL=errors.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.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",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"chalk": "^4.1.2",
|
|
73
73
|
"commander": "^8.3.0",
|
|
74
74
|
"comment-json": "^4.1.1",
|
|
75
|
-
"cspell-gitignore": "^5.
|
|
76
|
-
"cspell-glob": "^5.
|
|
77
|
-
"cspell-lib": "^5.
|
|
75
|
+
"cspell-gitignore": "^5.15.2",
|
|
76
|
+
"cspell-glob": "^5.15.2",
|
|
77
|
+
"cspell-lib": "^5.15.2",
|
|
78
78
|
"fast-json-stable-stringify": "^2.1.0",
|
|
79
79
|
"file-entry-cache": "^6.0.1",
|
|
80
80
|
"fs-extra": "^10.0.0",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"node": ">=12.13.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@cspell/cspell-json-reporter": "^5.
|
|
93
|
-
"@cspell/cspell-types": "^5.
|
|
92
|
+
"@cspell/cspell-json-reporter": "^5.15.2",
|
|
93
|
+
"@cspell/cspell-types": "^5.15.2",
|
|
94
94
|
"@types/file-entry-cache": "^5.0.2",
|
|
95
95
|
"@types/fs-extra": "^9.0.13",
|
|
96
96
|
"@types/glob": "^7.2.0",
|
|
@@ -98,10 +98,10 @@
|
|
|
98
98
|
"@types/micromatch": "^4.0.2",
|
|
99
99
|
"@types/minimatch": "^3.0.5",
|
|
100
100
|
"@types/semver": "^7.3.9",
|
|
101
|
-
"jest": "^27.4.
|
|
101
|
+
"jest": "^27.4.7",
|
|
102
102
|
"micromatch": "^4.0.4",
|
|
103
103
|
"minimatch": "^3.0.4",
|
|
104
104
|
"rimraf": "^3.0.2"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "b047b5458980010a8f3ab31c6dc9434e0e782d5e"
|
|
107
107
|
}
|