Skip to content

Commit

Permalink
fix: make config file version 0.2 by default. (#2186)
Browse files Browse the repository at this point in the history
This fixes issues with ignorePaths and overrides.
  • Loading branch information
Jason3S committed Jan 6, 2022
1 parent 9a9070b commit ed8af60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts
Expand Up @@ -6,6 +6,7 @@ import {
calcOverrideSettings,
checkFilenameMatchesGlob,
clearCachedSettingsFiles,
currentSettingsFileVersion,
ENV_CSPELL_GLOB_ROOT,
extractDependencies,
extractImportErrors,
Expand All @@ -32,6 +33,7 @@ const root = path.resolve(rootCspellLib, '../..');
const samplesDir = path.resolve(rootCspellLib, 'samples');
const samplesSrc = path.join(samplesDir, 'src');
const testFixtures = path.join(rootCspellLib, '../../test-fixtures');
const oc = expect.objectContaining;

jest.mock('../util/logger');

Expand Down Expand Up @@ -365,18 +367,23 @@ describe('Validate Glob resolution', () => {
expect(settingsV1).not.toEqual(sampleSettingsV1);

delete settingsV1.version;
expect(settingsV1).toEqual(sampleSettings);
const { version: _, ...sample } = sampleSettings;
expect(settingsV1).toEqual(sample);
});

test('Using ENV_CSPELL_GLOB_ROOT as without shared hierarchy', () => {
process.env[ENV_CSPELL_GLOB_ROOT] = path.resolve(__dirname, '../../samples');
const settingsV = normalizeSettings(rawSampleSettings, __filename, {});
const settingsV1 = normalizeSettings(rawSampleSettingsV1, __filename, {});

expect(settingsV.version).toEqual(currentSettingsFileVersion);

expect(settingsV1).toEqual(oc({ version: '0.1' }));
expect(settingsV).not.toEqual(sampleSettings);
expect(settingsV1).not.toEqual(sampleSettingsV1);

delete settingsV1.version;
delete settingsV.version;
expect(settingsV1).toEqual(settingsV);
});

Expand Down Expand Up @@ -661,10 +668,6 @@ function r(...parts: string[]): string {
return path.resolve(__dirname, p(...parts));
}

function oc<T>(v: Partial<T>): T {
return expect.objectContaining(v);
}

function relSamples(file: string) {
return path.resolve(samplesDir, file);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-lib/src/Settings/CSpellSettingsServer.ts
Expand Up @@ -28,7 +28,7 @@ type CSpellSettingsVersion = Exclude<CSpellSettings['version'], undefined>;
const supportedCSpellConfigVersions: CSpellSettingsVersion[] = ['0.2'];
const configSettingsFileVersion0_1 = '0.1';
const configSettingsFileVersion0_2 = '0.2';
const currentSettingsFileVersion = configSettingsFileVersion0_2;
export const currentSettingsFileVersion = configSettingsFileVersion0_2;

const setOfSupportedConfigVersions = new Set<string>(supportedCSpellConfigVersions);

Expand Down Expand Up @@ -151,6 +151,7 @@ function normalizeSettings(

// Fix up dictionaryDefinitions
const settings = {
version: defaultSettings.version,
...rawSettings,
id,
name,
Expand Down

0 comments on commit ed8af60

Please sign in to comment.