fixed missing cache issue
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a2677ef2a3
commit
b3d24f98ba
1 changed files with 3 additions and 1 deletions
2
index.js
2
index.js
|
@ -9,7 +9,9 @@ const nmap = require('libnmap');
|
||||||
let cachePath = path.resolve("./data/cache.json");
|
let cachePath = path.resolve("./data/cache.json");
|
||||||
const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {};
|
const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {};
|
||||||
// delete cache file to remove orphaned cache values
|
// delete cache file to remove orphaned cache values
|
||||||
|
if (fs.existsSync(cachePath)) {
|
||||||
fs.unlinkSync(cachePath);
|
fs.unlinkSync(cachePath);
|
||||||
|
}
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"});
|
fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"});
|
||||||
|
|
Reference in a new issue