Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
): t.Statement[] {
// eslint-disable-next-line no-undef
const file = Path.resolve(
__dirname,
`../templates/snippet/${specifier.replace(/\./g, '/').toLowerCase()}.js`,
);
if (!fs.existsSync(file)) {
throw new Error(
`Template file '${file}' not found. The type may be invalid or renamed due to an update.`,
);
}
const tpl = fs.readFileSync(file, 'utf8');
if (vars === undefined) {
return parse(tpl).program.body;
}
return template.statements(tpl, {
placeholderPattern: PLACEHOLDER_PATTERN,
})(vars);
}
export function statements(tpl: string, vars: { [x: string]: OneOrMore }): t.Statement[] {
return template.statements(tpl, {
placeholderPattern: PLACEHOLDER_PATTERN,
})(vars);
}