Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runTSParser(directory, files) {
for (const file of files) {
const result = tsParser.parse(
fs.readFileSync(path.join(__dirname, file), 'utf8'),
{
comment: true,
tokens: true
}
);
if (result.type !== 'Program') {
throw new Error('something went wrong');
}
}
}