From ad09a61ab7d93067575888c21eb0c71f8c790ce4 Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 20 Jul 2020 13:02:47 -0700 Subject: [PATCH] added directory check to init when making index md file --- brain/api/v1/auth.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/brain/api/v1/auth.js b/brain/api/v1/auth.js index b7a9c25..91888cb 100644 --- a/brain/api/v1/auth.js +++ b/brain/api/v1/auth.js @@ -206,13 +206,15 @@ router.post('/init', function (req, res) { '---\n' + index.content; - fs.writeFile('content/pages/index.md', init) - .then(() => { - console.log('index file created'); - }) - .catch(err => { - console.log('ERROR', err); - }); + fs.ensureDir('content/pages/').then(() => { + fs.writeFile('content/pages/index.md', init) + .then(() => { + //console.log('index file created'); + }) + .catch(() => { + //console.log('ERROR', err); + }); + }); }); res.json({