fix build citation rollup plugin to actually generate citation

This commit is contained in:
cchang-vassar 2024-09-13 09:45:27 -04:00
parent bab33ead69
commit 909cb9a768

View File

@ -22,7 +22,7 @@ export default function cffToJsonPlugin() {
// Try to find CITATION.cff file // Try to find CITATION.cff file
const citationCff = (() => { const citationCff = (() => {
try { try {
fs.readFileSync("./CITATION.cff", "utf-8").toString(); return fs.readFileSync("./CITATION.cff", "utf-8").toString();
} catch (error) { } catch (error) {
console.log(`Error finding CITATION.cff: ${error.message}`); console.log(`Error finding CITATION.cff: ${error.message}`);
return null; return null;
@ -42,13 +42,15 @@ export default function cffToJsonPlugin() {
2 2
); );
} catch (error) { } catch (error) {
console.log(`Error building citation from CITATION.cff: ${error.message}`); console.log(`Error converting CITATION.cff to JSON: ${error.message}`);
return null; return null;
} }
})(); })();
// Replace target string with citation JSON // Replace target string with citation JSON
if (!citationJson) return { code: code }; if (!citationJson) {
return { code: code };
}
const citationString = "citation: " + citationJson; const citationString = "citation: " + citationJson;
const startIndex = code.indexOf(targetString); const startIndex = code.indexOf(targetString);
if (startIndex !== -1) { if (startIndex !== -1) {