Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync in the test folder

In Node.js 14.14.0 the `fs.rmSync` function was added that removes files
and directories. The `recursive` option is used to remove directories
and their contents, making it a drop-in replacement for the `rimraf`
dependency we use.

Given that PDF.js now requires Node.js 18+ we can be sure that this
option is available, so we can safely remove `rimraf` and reduce the
number of project dependencies in the test folder.

This commit also gets rid of the indirection via the `removeDirSync`
test helper function by simply calling `fs.rmSync` directly.

Co-authored-by: Wojciech Maj <kontakt@wojtekmaj.pl>
This commit is contained in:
Tim van der Meij 2024-04-14 16:33:16 +02:00
parent e08de772ff
commit a562c41e12
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
2 changed files with 7 additions and 20 deletions

View file

@ -16,16 +16,6 @@
import fs from "fs";
import path from "path";
import rimraf from "rimraf";
const rimrafSync = rimraf.sync;
function removeDirSync(dir) {
fs.readdirSync(dir); // Will throw if dir is not a directory
rimrafSync(dir, {
disableGlob: true,
});
}
function copySubtreeSync(src, dest) {
const files = fs.readdirSync(src);
@ -63,4 +53,4 @@ function ensureDirSync(dir) {
}
}
export { copySubtreeSync, ensureDirSync, removeDirSync };
export { copySubtreeSync, ensureDirSync };