From c3f3b5b09cf2767251baebd3c4b91e2dd1373150 Mon Sep 17 00:00:00 2001 From: DABH Date: Wed, 3 Jan 2024 00:02:13 -0600 Subject: [PATCH] Fix all rimraf usages to the best of my ability; glob is not true by default in rimraf; file archive test only passed every other time using async rimraf, could use further investigation --- test/unit/winston/transports/01-file-maxsize.test.js | 2 +- test/unit/winston/transports/02-file-archive.test.js | 5 +++-- test/unit/winston/transports/file-archive.test.js | 2 +- test/unit/winston/transports/file-rotationFormat.test.js | 2 +- test/unit/winston/transports/file-tailrolling.test.js | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/unit/winston/transports/01-file-maxsize.test.js b/test/unit/winston/transports/01-file-maxsize.test.js index 921ef5313..90146acce 100644 --- a/test/unit/winston/transports/01-file-maxsize.test.js +++ b/test/unit/winston/transports/01-file-maxsize.test.js @@ -18,7 +18,7 @@ const MESSAGE = Symbol.for('message'); // Remove all log fixtures // function removeFixtures(done) { - rimraf(path.join(testLogFixturesPath, 'testmaxsize*')).then(() => done()); + rimraf(path.join(testLogFixturesPath, 'testmaxsize*'), {glob: true}).then(() => done()); } describe('File (maxsize)', function () { diff --git a/test/unit/winston/transports/02-file-archive.test.js b/test/unit/winston/transports/02-file-archive.test.js index b067775c4..fe0379f25 100644 --- a/test/unit/winston/transports/02-file-archive.test.js +++ b/test/unit/winston/transports/02-file-archive.test.js @@ -4,7 +4,7 @@ */ /* eslint-disable no-sync */ -const { rimraf } = require('rimraf'); +const { rimrafSync } = require('rimraf'); const fs = require('fs'); const path = require('path'); const { MESSAGE } = require('triple-beam'); @@ -22,7 +22,8 @@ const testLogFixturesPath = path.join( function removeFixtures(done) { - rimraf(path.join(testLogFixturesPath, 'testarchive*')).then(() => done()); + rimrafSync(path.join(testLogFixturesPath, 'testarchive*'), {glob: true}); + done(); } describe('winston/transports/file/zippedArchive', function () { diff --git a/test/unit/winston/transports/file-archive.test.js b/test/unit/winston/transports/file-archive.test.js index 311555a3c..09210689c 100644 --- a/test/unit/winston/transports/file-archive.test.js +++ b/test/unit/winston/transports/file-archive.test.js @@ -20,7 +20,7 @@ const { MESSAGE } = require('triple-beam'); // Remove all log fixtures // function removeFixtures(done) { - rimraf(path.join(testLogFixturesPath, 'testarchive*')).then(() => done()); + rimraf(path.join(testLogFixturesPath, 'testarchive*'), {glob: true}).then(() => done()); } diff --git a/test/unit/winston/transports/file-rotationFormat.test.js b/test/unit/winston/transports/file-rotationFormat.test.js index a4a64429c..a5ea39011 100644 --- a/test/unit/winston/transports/file-rotationFormat.test.js +++ b/test/unit/winston/transports/file-rotationFormat.test.js @@ -21,7 +21,7 @@ const testFileFixturesPath = path.join( // Remove all log fixtures // function removeFixtures(done) { - rimraf(path.join(testFileFixturesPath, 'rotation*')).then(() => done()); + rimraf(path.join(testFileFixturesPath, 'rotation*'), {glob: true}).then(() => done()); } // Validate Filename according to rotation diff --git a/test/unit/winston/transports/file-tailrolling.test.js b/test/unit/winston/transports/file-tailrolling.test.js index f89a2d177..7133bd031 100644 --- a/test/unit/winston/transports/file-tailrolling.test.js +++ b/test/unit/winston/transports/file-tailrolling.test.js @@ -12,7 +12,7 @@ const { MESSAGE } = require('triple-beam'); // Remove all log fixtures // function removeFixtures(done) { - rimraf(path.join(testLogFixturesPath, 'testtailrollingfiles*')).then(() => done()); + rimraf(path.join(testLogFixturesPath, 'testtailrollingfiles*'), {glob: true}).then(() => done()); }