Add error msg when extensionsPath is not found

This commit is contained in:
Ramya Achutha Rao 2017-08-26 13:20:28 -07:00
Родитель 2625546266
Коммит d00358daea
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "vscode-emmet-helper",
"version": "1.0.19",
"version": "1.0.20",
"description": "Helper to use emmet modules in Visual Studio Code",
"main": "./out/emmetHelper.js",
"types": "./out/emmetHelper.d.ts",
@ -24,7 +24,7 @@
"vscode-languageserver-types": "^3.0.3"
},
"scripts": {
"prepublish": "npm run compile",
"prepublish": "npm run compile && npm run test",
"compile": "tsc -p ./ && cpy ./src/expand/*.js ./out/expand",
"test": "mocha out/test"
}

Просмотреть файл

@ -444,13 +444,18 @@ function getVariables(variablesFromSettings: object): any {
* Updates customizations from snippets.json and syntaxProfiles.json files in the directory configured in emmet.extensionsPath setting
*/
export function updateExtensionsPath(emmetExtensionsPath: string): Promise<void> {
if (!emmetExtensionsPath || !emmetExtensionsPath.trim() || !path.isAbsolute(emmetExtensionsPath.trim()) || !dirExists(emmetExtensionsPath.trim())) {
customSnippetRegistry = {};
snippetKeyCache.clear();
profilesFromFile = {};
variablesFromFile = {};
if (!emmetExtensionsPath || !emmetExtensionsPath.trim()) {
resetSettingsFromFile();
return Promise.resolve();
}
if (!path.isAbsolute(emmetExtensionsPath.trim())) {
resetSettingsFromFile();
return Promise.reject('The path provided in emmet.extensionsPath setting should be absoulte path');
}
if (!dirExists(emmetExtensionsPath.trim())) {
resetSettingsFromFile();
return Promise.reject(`The directory ${emmetExtensionsPath.trim()} doesnt exist. Update emmet.extensionsPath setting`);
}
let dirPath = emmetExtensionsPath.trim();
let snippetsPath = path.join(dirPath, 'snippets.json');
@ -516,6 +521,13 @@ function dirExists(dirPath: string): boolean {
}
}
function resetSettingsFromFile(){
customSnippetRegistry = {};
snippetKeyCache.clear();
profilesFromFile = {};
variablesFromFile = {};
}
/**
* Get the corresponding emmet mode for given vscode language mode
* Eg: jsx for typescriptreact/javascriptreact or pug for jade