Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function parseCSL(
filepath: string,
isIndependent: boolean,
): Promise {
const xml = await readfile(filepath, { encoding: 'utf-8' });
const data: StyleQuery = await transform(xml, {
kind: '/style/@class',
hasBibliography: 'boolean(/style/bibliography)',
parent: '/style/info/link[@rel="independent-parent"]/@href',
title: '/style/info/title',
shortTitle: '/style/info/title-short',
updated: '/style/info/updated',
});
return data.kind === 'note' || (isIndependent && !data.hasBibliography)
? []
: [
{
kind: StyleKind.PREDEFINED,
value: path.basename(
isIndependent ? filepath : data.parent,
'.csl',
),