From 5b325c4ae5c0155124c5f1d434255dd7f037f2cb Mon Sep 17 00:00:00 2001 From: sora Date: Wed, 23 Oct 2019 11:11:35 +0200 Subject: [PATCH] fix --- jsondb.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jsondb.js b/jsondb.js index 5d147cc..02f8d03 100644 --- a/jsondb.js +++ b/jsondb.js @@ -21,7 +21,10 @@ module.exports = function(name){ this.init = function(){ fs.readFile(this.file, (err, data) => { - if (err) throw err; + if (err.errno==-2 && err.code == "ENOENT"){ + this.set(db); + return; + }else if (err) throw err; this.json = JSON.parse(data); }); }