diff --git a/lib/kv-store.mjs b/lib/kv-store.mjs index 4d7a003..a2d096c 100644 --- a/lib/kv-store.mjs +++ b/lib/kv-store.mjs @@ -151,12 +151,14 @@ export class Simple_KeyValue_Store { load() { const { data, storage_path } = this; - if (!fs.existsSync(storage_path)) { - return; + let file_contents; + try { + file_contents = fs.readFileSync(storage_path, 'utf-8'); + } catch (e) { + if (e.code === 'ENOENT') { return; } + throw e; } - const file_contents = fs.readFileSync(storage_path, 'utf-8'); - for (const line of file_contents.split('\n')) { if (!line) continue; const [key, value] = JSON.parse(line);