Skip to content

Commit

Permalink
chore: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mdluo committed Aug 15, 2020
1 parent f6ae844 commit 5f34ef8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function getReviewShow(id: number): Promise<Goodreads.Review> {
export async function updateGist(
title: string,
content: string
): Promise<void> {
): Promise<string> {
const gist_id = process.env.GIST_ID || '';
const gist = await octokit.gists.get({ gist_id });
const filename = Object.keys(gist.data.files)[0];
Expand All @@ -54,4 +54,5 @@ export async function updateGist(
},
},
});
return gist.url;
}
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ function generateLines(books: Book[]) {
(async () => {
try {
const books = await getBooks();
console.log(`Found ${books.length} book(s)`);
const lines = generateLines(books);
await api.updateGist(
const url = await api.updateGist(
`📚 Currently reading books (${lines.length}${books.length})`,
lines.join('\n')
);
console.log(`Updated: ${url}`);
} catch (error) {
console.error(error);
process.exit(1);
Expand Down

0 comments on commit 5f34ef8

Please sign in to comment.