Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile(snippetsPath, (err, snippetsData) => {
if (err) {
return reject(`Error while fetching the file ${snippetsPath}`);
}
try {
let errors = [];
let snippetsJson = JSONC.parse(snippetsData.toString(), errors);
if (errors.length > 0) {
return reject(`Found error ${JSONC.ScanError[errors[0].error]} while parsing the file ${snippetsPath} at offset ${errors[0].offset}`);
}
variablesFromFile = snippetsJson['variables'];
customSnippetRegistry = {};
snippetKeyCache.clear();
Object.keys(snippetsJson).forEach(syntax => {
if (!snippetsJson[syntax]['snippets']) {
return;
}
let baseSyntax = isStyleSheet(syntax) ? 'css' : 'html';
let customSnippets = snippetsJson[syntax]['snippets'];
if (snippetsJson[baseSyntax] && snippetsJson[baseSyntax]['snippets'] && baseSyntax !== syntax) {
customSnippets = Object.assign({}, snippetsJson[baseSyntax]['snippets'], snippetsJson[syntax]['snippets']);
}
if (!isStyleSheet(syntax)) {
// In Emmet 2.0 all snippets should be valid abbreviations
// Convert old snippets that do not follow this format to new format
fs.readFile(snippetsPath, (err, snippetsData) => {
if (err) {
return reject(`Error while fetching the file ${snippetsPath}`);
}
try {
let errors = [];
let snippetsJson = JSONC.parse(snippetsData.toString(), errors);
if (errors.length > 0) {
return reject(`Found error ${JSONC.ScanError[errors[0].error]} while parsing the file ${snippetsPath} at offset ${errors[0].offset}`);
}
variablesFromFile = snippetsJson['variables'];
customSnippetRegistry = {};
snippetKeyCache.clear();
Object.keys(snippetsJson).forEach(syntax => {
if (!snippetsJson[syntax]['snippets']) {
return;
}
let baseSyntax = isStyleSheet(syntax) ? 'css' : 'html';
let customSnippets = snippetsJson[syntax]['snippets'];
if (snippetsJson[baseSyntax] && snippetsJson[baseSyntax]['snippets'] && baseSyntax !== syntax) {
customSnippets = Object.assign({}, snippetsJson[baseSyntax]['snippets'], snippetsJson[syntax]['snippets'])
}
if (!isStyleSheet(syntax)) {
// In Emmet 2.0 all snippets should be valid abbreviations
// Convert old snippets that do not follow this format to new format