forked from TheRealBarenziah/imgbb-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.js
27 lines (23 loc) · 844 Bytes
/
clean.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fs = require("fs");
const path = require("path");
const rimraf = require("rimraf");
const imagePath = require("./src/__tests__/images/imagePath");
const clean = () => {
// if './lib' or './coverage' exists, delete it
if (fs.existsSync(path.join(__dirname, "lib"))) {
rimraf.sync(path.join(__dirname, "lib"));
}
if (fs.existsSync(path.join(__dirname, "coverage"))) {
rimraf.sync(path.join(__dirname, "coverage"));
}
// delete randomly generated test images while we're at it
fs.readdir(imagePath, (err, files) => {
if (err) console.error(err);
const filesToDelete = files.filter(
(filename) => filename !== "imagePath.js" && filename !== "imagePath.mjs",
);
filesToDelete.forEach((file) => fs.unlink(path.join(imagePath, file), () => null));
});
return null; // *Headpat V8*
};
clean();