feat: allow customizing history json filename

This commit is contained in:
2019-02-28 17:15:31 -07:00
parent ad3ebecb62
commit 7bf6ff373d

View File

@@ -5,8 +5,8 @@ const MAX_ITEMS = 1000; // max entries in history
const TRUNCATE_AMOUNT = 200; // count of entries to remove when max is hit const TRUNCATE_AMOUNT = 200; // count of entries to remove when max is hit
export default class History { export default class History {
constructor() { constructor(filename = 'history.json') {
this.filePath = path.resolve('data', 'history.json'); this.filePath = path.resolve('data', filename);
try { try {
const data = fs.readFileSync(this.filePath); const data = fs.readFileSync(this.filePath);
this.db = data.length === 0 ? [] : JSON.parse(data); this.db = data.length === 0 ? [] : JSON.parse(data);