From 9e965aab1836b1cbc11b2ef75fea03857e44837f Mon Sep 17 00:00:00 2001
From: Dominik Sigmund <dominik.sigmund@br.de>
Date: Wed, 30 Jan 2019 09:21:26 +0100
Subject: [PATCH] Better File Checks!

---
 index.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index 3bbb2a3..9f79582 100644
--- a/index.js
+++ b/index.js
@@ -28,10 +28,17 @@ function Log (options) {
     this.fs = require('fs')
     this.path = require('path')
     this.options.file = this.path.resolve(this.options.file)
+    if (!this.fs.lstatSync(this.options.file).isFile()) {
+      throw new Error(this.options.file + ' is not a File...')
+    }
     try {
       this.fs.accessSync(this.options.file, this.fs.constants.R_OK | this.fs.constants.W_OK)
     } catch (err) {
-      this.fs.writeFileSync(this.options.file, '')
+      try {
+        this.fs.writeFileSync(this.options.file, '')
+      } catch (err) {
+        throw new Error('Could not Create File ' + this.options.file + '\n' + err.toString())
+      }
     }
   }
   this.info = function (message, tags) {
-- 
GitLab