diff --git a/packages/lib/RotatingLogs.test.ts b/packages/lib/RotatingLogs.test.ts index a0acb38fc..a8990a537 100644 --- a/packages/lib/RotatingLogs.test.ts +++ b/packages/lib/RotatingLogs.test.ts @@ -12,7 +12,7 @@ describe('RotatingLogs', () => { try { dir = await createTempDir(); await createTestLogFile(dir); - let files: string[] = await readdir(dir); + let files = await readdir(dir); expect(files.find(file => file.match(/^log.txt$/gi))).toBeTruthy(); expect(files.length).toBe(1); const rotatingLogs: RotatingLogs = new RotatingLogs(dir, 1, 1); @@ -35,7 +35,7 @@ describe('RotatingLogs', () => { await rotatingLogs.cleanActiveLogFile(); await msleep(1); await rotatingLogs.deleteNonActiveLogFiles(); - const files: string[] = await readdir(dir); + const files = await readdir(dir); expect(files.find(file => file.match(/^log-[0-9]+.txt$/gi))).toBeFalsy(); expect(files.length).toBe(0); } finally { @@ -52,7 +52,7 @@ describe('RotatingLogs', () => { const rotatingLogs: RotatingLogs = new RotatingLogs(dir, 1, 100); await rotatingLogs.cleanActiveLogFile(); await rotatingLogs.deleteNonActiveLogFiles(); - const files: string[] = await readdir(dir); + const files = await readdir(dir); expect(files.find(file => file.match(/^log-[0-9]+.txt$/gi))).toBeTruthy(); expect(files.length).toBe(1); } finally { diff --git a/packages/lib/RotatingLogs.ts b/packages/lib/RotatingLogs.ts index b3ade3c7a..e1446f840 100644 --- a/packages/lib/RotatingLogs.ts +++ b/packages/lib/RotatingLogs.ts @@ -29,7 +29,7 @@ export default class RotatingLogs { const files: Stat[] = await this.fsDriver().readDirStats(this.logFilesDir); for (const file of files) { if (!file.path.match(/^log-[0-9]+.txt$/gi)) continue; - const timestamp: string = file.path.match(/[0-9]+/g)[0]; + const timestamp: number = parseInt(file.path.match(/[0-9]+/g)[0], 10); const ageOfTheFile: number = Date.now() - timestamp; if (ageOfTheFile >= this.inactiveMaxAge) { await this.fsDriver().remove(this.logFileFullpath(file.path));