Skip to content

Commit 735566c

Browse files
committed
fix: improve create post
1 parent d0e313c commit 735566c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/command/post/create.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mkdir, readFile, writeFile } from 'fs/promises'
1+
import { mkdir, readFile } from 'fs/promises'
22
import path from 'path'
33
import { spawnSync } from 'child_process'
44
import { createCommand } from 'commander'
@@ -38,10 +38,12 @@ export const createPost = async ({ content, topic }: CreateOptions) => {
3838
draftDir,
3939
`${format(new Date(), 'yyyy-MM-dd-HH-mm-ss')}.txt`
4040
)
41-
await writeFile(draftFile, '', 'utf-8')
4241
spawnSync('vim', [draftFile], { stdio: 'inherit' })
4342

44-
content = await readFile(draftFile, 'utf-8')
43+
content = await readFile(draftFile, 'utf-8').catch((err) => {
44+
logger.warning(err)
45+
return ''
46+
})
4547
}
4648

4749
content = content?.trim()

0 commit comments

Comments
 (0)