feat: allow customizing history json filename
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user