Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ts = 'source.ts',
tsx = 'source.tsx'
}
const grammarFileNames: Record = {
[GrammarKind.ts]: "TypeScript.tmLanguage",
[GrammarKind.tsx]: "TypeScriptReact.tmLanguage"
};
function grammarPath(kind: GrammarKind) {
return path.join(__dirname, '..', grammarFileNames[kind]);
}
const grammarPaths = {
[GrammarKind.ts]: grammarPath(GrammarKind.ts),
[GrammarKind.tsx]: grammarPath(GrammarKind.tsx)
};
const registery = new vt.Registry({
loadGrammar: function (scopeName: GrammarKind) {
const path = grammarPaths[scopeName];
if (path) {
return new Promise((resolve, reject) => {
fs.readFile(path, (error, content) => {
if (error) {
reject(error);
} else {
const rawGrammar = vt.parseRawGrammar(content.toString(), path);
resolve(rawGrammar);
}
});
});
}
return Promise.resolve(null);