Skip to content

Commit

Permalink
Merge e6413cb into ecf9ee8
Browse files Browse the repository at this point in the history
  • Loading branch information
tribut committed May 13, 2019
2 parents ecf9ee8 + e6413cb commit da15498
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/cspell/src/Settings/DictionarySettings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from 'chai';
import * as DictSettings from './DictionarySettings';
import * as fsp from 'fs-extra';
import * as path from 'path';
import * as os from 'os';
import { getDefaultSettings } from './DefaultSettings';

const defaultSettings = getDefaultSettings();
Expand Down Expand Up @@ -50,6 +52,11 @@ describe('Validate DictionarySettings', () => {
expect(dictionaryDefinitions).to.not.be.empty;
const defs = DictSettings.normalizePathForDictDefs(dictionaryDefinitions!, '.');
expect(defs.length).to.be.equal(dictionaryDefinitions!.length);

const basePath = path.join('some', 'dir');
dictionaryDefinitions![0].path = path.join('~', basePath);
const tildeDefs = DictSettings.normalizePathForDictDefs(dictionaryDefinitions!, '.');
expect(tildeDefs[0].path).to.be.equal(path.join(os.homedir(), basePath));
});
});

3 changes: 2 additions & 1 deletion packages/cspell/src/Settings/DictionarySettings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DictionaryDefinition, DictionaryId } from './CSpellSettingsDef';
import * as path from 'path';
import * as os from 'os';

const dictionaryPath = () => path.join(__dirname, '..', '..', 'dist', 'dictionaries');

Expand Down Expand Up @@ -46,7 +47,7 @@ export function normalizePathForDictDef(def: DictionaryDefinition, defaultPath:
const absPath = relPath.match(/^\./) ? path.join(defaultPath, relPath) : relPath;
return {
...def,
path: absPath
path: absPath.replace(/^~/, os.homedir())
};
}

0 comments on commit da15498

Please sign in to comment.