Update compose.js

If for any reason the `data/blog` directory is not present, the script fails. This change creates the `data/blog` directory if it doesn't yet exist.
This commit is contained in:
Edwin Coronado 2022-01-23 23:07:20 -08:00 committed by GitHub
parent e6db5e62cd
commit ac7d1c29cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,7 @@ inquirer
.replace(/ /g, '-')
.replace(/-+/g, '-')
const frontMatter = genFrontMatter(answers)
if (!fs.existsSync('data/blog', { recursive: true })) fs.mkdirSync('data/blog')
const filePath = `data/blog/${fileName ? fileName : 'untitled'}.${
answers.extension ? answers.extension : 'md'
}`