Skip to content

Commit 3045301

Browse files
✨ Support custom file name
1 parent d2bb34b commit 3045301

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export const fetchGoogleDocsFiles = async (files: string[]) => {
2020
console.log("\nDownloading document", documentId);
2121
try {
2222
const result = await docs.documents.get({
23-
documentId,
23+
documentId: documentId.split(":")[0],
2424
auth: oauth2Client,
2525
});
2626
if (!result.data.title) throw new Error("Title not found");
27-
await fs.writeFile(
28-
join(".", `${result.data.title}.md`),
29-
googleDocsToMarkdown(result.data)
30-
);
27+
const title = documentId.includes(":")
28+
? documentId.split(":")[1]
29+
: `${result.data.title}.md`;
30+
await fs.writeFile(join(".", title), googleDocsToMarkdown(result.data));
3131
console.log("Downloaded document", result.data.title);
3232
} catch (error) {
3333
console.log("Got an error", error);

0 commit comments

Comments
 (0)