From b3d24f98ba3c72da2a6361585ad89a1ca4e92c67 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Thu, 27 Feb 2020 20:41:56 +0100 Subject: [PATCH] fixed missing cache issue --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a17c44f..69b8e0a 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,9 @@ const nmap = require('libnmap'); let cachePath = path.resolve("./data/cache.json"); const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {}; // delete cache file to remove orphaned cache values -fs.unlinkSync(cachePath); +if (fs.existsSync(cachePath)) { + fs.unlinkSync(cachePath); +} process.on('SIGINT', () => { fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"});