make glob as an optional dependency
jimmywarting opened this issue · 2 comments
Glob make up for 149kB for the total of 165kB install size.
Which I think is pretty much.
https://npm.anvaka.com/#/view/2d/rimraf
https://packagephobia.now.sh/result?p=rimraf
Often you know what folder/file you would like to delete so any magical pattern is not always necessary.
rimraf is more then what I'm asking for. All I want is to remove a folder recursive.
Thinking this statement isn't really true:
The UNIX command rm -rf for node.
rm
is not able to delete a pattern of files? it's more like a find & remove
find ./ -name ".orig" -exec rm -rf {} \;
Sometimes you have to consider your option if a such large dependency is really necessary and perhaps just inline some code yourself or try to find a other package.
const fs = require('fs')
const afs = fs.promises;
async function deleteFolderRecursive(path) {
if (fs.existsSync(path)) {
for (let entry of await afs.readdir(path)) {
(await afs.lstat(fs.join(path, entry))).isDirectory()
? await deleteFolderRecursive(curPath)
: await afs.unlink(curPath)
}
await afs.rmdir(path)
}
}
Even better: glob removed in v4.
Or even better (now that nodejs supports rm recursive natively from v14) fsPromises.rm(path, { recursive: true })