diff --git a/dist/index.js b/dist/index.js index dc222507..920f5c7d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -140959,16 +140959,16 @@ function mTags({ tags }) { ;// CONCATENATED MODULE: ./src/summary.ts -function summaryMarkdown(library, date, bookStatus) { +function summaryMarkdown(library, dateType, bookStatus) { const { BookTitle } = process.env; return `# Updated library ${capitalize(`${bookStatus}`)}: “${BookTitle}” -Date: ${date} +Date: ${dateType.dateFinished} Book status: ${bookStatus} -Result: ${bookStatus === "finished" && date} -${bookStatus === "finished" && date - ? yearReviewSummary(library, date.slice(0, 4)) +Result: ${bookStatus === "finished" && dateType.dateFinished} +${bookStatus === "finished" && dateType.dateFinished + ? yearReviewSummary(library, dateType.dateFinished.slice(0, 4)) : ""} `; } @@ -141256,7 +141256,9 @@ async function read() { } library = sortByDate(library); await returnWriteFile(filename, library); - await core.summary.addRaw(summaryMarkdown(library, date, bookStatus)).write(); + await core.summary + .addRaw(summaryMarkdown(library, dateType, bookStatus)) + .write(); } catch (error) { (0,core.setFailed)(error); diff --git a/src/index.ts b/src/index.ts index b892187b..5713584b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,7 +105,9 @@ export async function read() { library = sortByDate(library); await returnWriteFile(filename, library); - await summary.addRaw(summaryMarkdown(library, date, bookStatus)).write(); + await summary + .addRaw(summaryMarkdown(library, dateType, bookStatus)) + .write(); } catch (error) { setFailed(error); } diff --git a/src/summary.ts b/src/summary.ts index 87c58444..7a8253a8 100644 --- a/src/summary.ts +++ b/src/summary.ts @@ -9,23 +9,23 @@ import { mTopAuthors, mTags, } from "./summary-markdown"; -import { capitalize } from "./utils"; +import { capitalize, DateTypes } from "./utils"; export function summaryMarkdown( library: NewBook[], - date: BookPayload["date"], + dateType: DateTypes, bookStatus: BookStatus ): string { const { BookTitle } = process.env; return `# Updated library ${capitalize(`${bookStatus}`)}: “${BookTitle}” -Date: ${date} +Date: ${dateType.dateFinished} Book status: ${bookStatus} -Result: ${bookStatus === "finished" && date} +Result: ${bookStatus === "finished" && dateType.dateFinished} ${ - bookStatus === "finished" && date - ? yearReviewSummary(library, date.slice(0, 4)) + bookStatus === "finished" && dateType.dateFinished + ? yearReviewSummary(library, dateType.dateFinished.slice(0, 4)) : "" } `; diff --git a/src/utils.ts b/src/utils.ts index 40e4cbe1..5e50bf8e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -89,18 +89,20 @@ function localDate() { return dateFormat.format(new Date()); } +export type DateTypes = { + dateAbandoned?: string; + dateStarted?: string; + dateFinished?: string; + dateAdded?: string; +}; + export function getBookStatus({ date, bookStatus, }: { date?: string; bookStatus?: BookStatus; -}): { - dateAbandoned?: string; - dateStarted?: string; - dateFinished?: string; - dateAdded?: string; -} { +}): DateTypes { const dateValue = date ?? localDate(); switch (bookStatus) { case "abandoned":