Skip to content

Commit

Permalink
chore: get rid of glob dependencies by switching del with rimraf (web…
Browse files Browse the repository at this point in the history
…pack#4258)

Replacing del gets rid of about 10 extra dependencies,
most are related to globbing, like globby, fast-glob and dir-glob.

del wraps rimraf in promisify and adds
1. more sophisticated globbing
2. deletion of multiple files at once by passing an array
3. a check to prevent deleting the current working directory and outside

Since the code base does not use any of the extra features,
we can just wrap rimraf with promisify instead of using del.

Co-authored-by: Nitin Kumar <[email protected]>
  • Loading branch information
ludofischer and snitin315 authored Feb 18, 2022
1 parent c64bd94 commit 628a82b
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 372 deletions.
6 changes: 4 additions & 2 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,15 @@ class Server {

// cert is more than 30 days old, kill it with fire
if ((now - Number(certificateStat.ctime)) / certificateTtl > 30) {
const del = require("del");
const { promisify } = require("util");
const rimraf = require("rimraf");
const del = promisify(rimraf);

this.logger.info(
"SSL certificate is more than 30 days old. Removing..."
);

await del([certificatePath], { force: true });
await del(certificatePath);

certificateExists = false;
}
Expand Down
Loading

0 comments on commit 628a82b

Please sign in to comment.