Skip to content

Commit c30fd7e

Browse files
authored
⚠️ Warn if article and journal doi prefixes do not match (#9)
1 parent 6d55970 commit c30fd7e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.changeset/wild-comics-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"crossref-utils": patch
3+
---
4+
5+
Warn if article and journal doi prefixes do not match

src/cli/deposit.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,13 @@ export async function deposit(session: ISession, opts: DepositOptions) {
468468

469469
let body: Element;
470470
if (depositType === 'journal') {
471-
if (!journalTitle || !journalDoi) throw new Error('Journal title and DOI are required');
471+
if (!journalTitle) throw new Error('Journal title is required');
472+
if (!journalDoi) throw new Error('Journal DOI is required');
472473
let journalIssue: JournalIssue | undefined;
473474
console.log('Deposit summary:');
474475
console.log(' Journal:');
475476
console.log(` Title: ${journalTitle}${journalAbbr ? ` (${journalAbbr})` : ''}`);
476-
if (journalDoi) console.log(` Doi: ${journalDoi}`);
477+
console.log(` Doi: ${journalDoi}`);
477478
if (volumeNumber || issueNumber || issueDoi) {
478479
if (!publicationDate) {
479480
throw new Error(`publication date is required for journal issue`);
@@ -492,10 +493,17 @@ export async function deposit(session: ISession, opts: DepositOptions) {
492493
};
493494
}
494495
console.log(' Articles:');
496+
const journalDoiPrefix = journalDoi.split('/')[0];
495497
depositArticles.forEach(({ frontmatter }) => {
496498
console.log(
497499
` ${frontmatter.doi} - ${frontmatter.title?.slice(0, 30)}${(frontmatter.title?.length ?? 0) > 30 ? '...' : ''}`,
498500
);
501+
const articleDoiPrefix = frontmatter.doi?.split('/')[0];
502+
if (journalDoiPrefix !== articleDoiPrefix) {
503+
session.log.warn(
504+
` Article DOI prefix ${articleDoiPrefix} does not match Journal DOI prefix ${journalDoiPrefix}`,
505+
);
506+
}
499507
});
500508
body = journalXml(
501509
{

0 commit comments

Comments
 (0)