cspell-lib 8.4.1 → 8.6.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.
|
@@ -144,11 +144,23 @@ declare function resolveGlobRoot(settings: CSpellSettingsWST, urlSettingsFile: U
|
|
|
144
144
|
declare function validateRawConfigVersion(config: CSpellConfigFile): void;
|
|
145
145
|
export declare function createConfigLoader(fs?: VFileSystem): IConfigLoader;
|
|
146
146
|
export declare function getDefaultConfigLoaderInternal(): ConfigLoaderInternal;
|
|
147
|
+
export declare class ConfigurationLoaderError extends Error {
|
|
148
|
+
readonly configurationFile?: string | undefined;
|
|
149
|
+
readonly relativeTo?: string | URL | undefined;
|
|
150
|
+
constructor(message: string, configurationFile?: string | undefined, relativeTo?: string | URL | undefined, cause?: unknown);
|
|
151
|
+
}
|
|
152
|
+
export declare class ConfigurationLoaderFailedToResolveError extends ConfigurationLoaderError {
|
|
153
|
+
readonly configurationFile: string;
|
|
154
|
+
readonly relativeTo: string | URL;
|
|
155
|
+
constructor(configurationFile: string, relativeTo: string | URL, cause?: unknown);
|
|
156
|
+
}
|
|
157
|
+
declare function relativeToCwd(file: string | URL): string;
|
|
147
158
|
export declare const __testing__: {
|
|
148
159
|
getDefaultConfigLoaderInternal: typeof getDefaultConfigLoaderInternal;
|
|
149
160
|
normalizeCacheSettings: typeof normalizeCacheSettings;
|
|
150
161
|
validateRawConfigVersion: typeof validateRawConfigVersion;
|
|
151
162
|
resolveGlobRoot: typeof resolveGlobRoot;
|
|
163
|
+
relativeToCwd: typeof relativeToCwd;
|
|
152
164
|
};
|
|
153
165
|
export {};
|
|
154
166
|
//# sourceMappingURL=configLoader.d.ts.map
|
|
@@ -12,7 +12,7 @@ import { AutoResolveCache } from '../../../util/AutoResolve.js';
|
|
|
12
12
|
import { logError, logWarning } from '../../../util/logger.js';
|
|
13
13
|
import { FileResolver } from '../../../util/resolveFile.js';
|
|
14
14
|
import { envToTemplateVars } from '../../../util/templates.js';
|
|
15
|
-
import { addTrailingSlash, cwdURL, resolveFileWithURL, toFilePathOrHref, windowsDriveLetterToUpper, } from '../../../util/url.js';
|
|
15
|
+
import { addTrailingSlash, cwdURL, resolveFileWithURL, toFilePathOrHref, toFileUrl, windowsDriveLetterToUpper, } from '../../../util/url.js';
|
|
16
16
|
import { configSettingsFileVersion0_1, configSettingsFileVersion0_2, currentSettingsFileVersion, defaultConfigFileModuleRef, ENV_CSPELL_GLOB_ROOT, } from '../../constants.js';
|
|
17
17
|
import { getMergeStats, mergeSettings } from '../../CSpellSettingsServer.js';
|
|
18
18
|
import { getGlobalConfig } from '../../GlobalSettings.js';
|
|
@@ -351,7 +351,7 @@ export class ConfigLoader {
|
|
|
351
351
|
}
|
|
352
352
|
return {
|
|
353
353
|
filename: r.filename.startsWith('file:/') ? fileURLToPath(r.filename) : r.filename,
|
|
354
|
-
error: r.found ? undefined : new
|
|
354
|
+
error: r.found ? undefined : new ConfigurationLoaderFailedToResolveError(filename, relativeTo),
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
get isTrusted() {
|
|
@@ -454,10 +454,58 @@ async function isDirectory(fs, path) {
|
|
|
454
454
|
return false;
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
+
export class ConfigurationLoaderError extends Error {
|
|
458
|
+
configurationFile;
|
|
459
|
+
relativeTo;
|
|
460
|
+
constructor(message, configurationFile, relativeTo, cause) {
|
|
461
|
+
super(message);
|
|
462
|
+
this.configurationFile = configurationFile;
|
|
463
|
+
this.relativeTo = relativeTo;
|
|
464
|
+
this.name = 'Configuration Loader Error';
|
|
465
|
+
if (cause) {
|
|
466
|
+
this.cause = cause;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
export class ConfigurationLoaderFailedToResolveError extends ConfigurationLoaderError {
|
|
471
|
+
configurationFile;
|
|
472
|
+
relativeTo;
|
|
473
|
+
constructor(configurationFile, relativeTo, cause) {
|
|
474
|
+
const filename = configurationFile.startsWith('file:/') ? fileURLToPath(configurationFile) : configurationFile;
|
|
475
|
+
const relSource = relativeToCwd(relativeTo);
|
|
476
|
+
const message = `Failed to resolve configuration file: "${filename}" referenced from "${relSource}"`;
|
|
477
|
+
super(message, configurationFile, relativeTo, cause);
|
|
478
|
+
this.configurationFile = configurationFile;
|
|
479
|
+
this.relativeTo = relativeTo;
|
|
480
|
+
// this.name = 'Configuration Loader Error';
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function relativeToCwd(file) {
|
|
484
|
+
const url = toFileUrl(file);
|
|
485
|
+
const cwdPath = cwdURL().pathname.split('/').slice(0, -1);
|
|
486
|
+
const urlPath = url.pathname.split('/');
|
|
487
|
+
if (urlPath[0] !== cwdPath[0])
|
|
488
|
+
return toFilePathOrHref(file);
|
|
489
|
+
let i = 0;
|
|
490
|
+
for (; i < cwdPath.length; ++i) {
|
|
491
|
+
if (cwdPath[i] !== urlPath[i])
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
const segments = cwdPath.length - i;
|
|
495
|
+
if (segments > 3)
|
|
496
|
+
return toFilePathOrHref(file);
|
|
497
|
+
const prefix = '.'
|
|
498
|
+
.repeat(segments)
|
|
499
|
+
.split('')
|
|
500
|
+
.map(() => '..')
|
|
501
|
+
.join('/');
|
|
502
|
+
return [prefix || '.', ...urlPath.slice(i)].join('/');
|
|
503
|
+
}
|
|
457
504
|
export const __testing__ = {
|
|
458
505
|
getDefaultConfigLoaderInternal,
|
|
459
506
|
normalizeCacheSettings,
|
|
460
507
|
validateRawConfigVersion,
|
|
461
508
|
resolveGlobRoot,
|
|
509
|
+
relativeToCwd,
|
|
462
510
|
};
|
|
463
511
|
//# sourceMappingURL=configLoader.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -58,23 +58,23 @@
|
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cspell/cspell-bundled-dicts": "8.
|
|
62
|
-
"@cspell/cspell-pipe": "8.
|
|
63
|
-
"@cspell/cspell-resolver": "8.
|
|
64
|
-
"@cspell/cspell-types": "8.
|
|
65
|
-
"@cspell/dynamic-import": "8.
|
|
66
|
-
"@cspell/strong-weak-map": "8.
|
|
61
|
+
"@cspell/cspell-bundled-dicts": "8.6.0",
|
|
62
|
+
"@cspell/cspell-pipe": "8.6.0",
|
|
63
|
+
"@cspell/cspell-resolver": "8.6.0",
|
|
64
|
+
"@cspell/cspell-types": "8.6.0",
|
|
65
|
+
"@cspell/dynamic-import": "8.6.0",
|
|
66
|
+
"@cspell/strong-weak-map": "8.6.0",
|
|
67
67
|
"clear-module": "^4.1.2",
|
|
68
68
|
"comment-json": "^4.2.3",
|
|
69
69
|
"configstore": "^6.0.0",
|
|
70
|
-
"cspell-config-lib": "8.
|
|
71
|
-
"cspell-dictionary": "8.
|
|
72
|
-
"cspell-glob": "8.
|
|
73
|
-
"cspell-grammar": "8.
|
|
74
|
-
"cspell-io": "8.
|
|
75
|
-
"cspell-trie-lib": "8.
|
|
70
|
+
"cspell-config-lib": "8.6.0",
|
|
71
|
+
"cspell-dictionary": "8.6.0",
|
|
72
|
+
"cspell-glob": "8.6.0",
|
|
73
|
+
"cspell-grammar": "8.6.0",
|
|
74
|
+
"cspell-io": "8.6.0",
|
|
75
|
+
"cspell-trie-lib": "8.6.0",
|
|
76
76
|
"fast-equals": "^5.0.1",
|
|
77
|
-
"gensequence": "^
|
|
77
|
+
"gensequence": "^7.0.0",
|
|
78
78
|
"import-fresh": "^3.3.0",
|
|
79
79
|
"resolve-from": "^5.0.0",
|
|
80
80
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"leaked-handles": "^5.2.0",
|
|
98
98
|
"lorem-ipsum": "^2.0.8"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "78eadb48e8ab400f4fcd159344c5b15968d7ab2e"
|
|
101
101
|
}
|