Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make config file version 0.2 by default. #2186

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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