Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): remove del dependency #4017

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"copy-template-dir": "^1.4.0",
"debug": "^4.1.1",
"decache": "^4.6.0",
"del": "^6.0.0",
"dot-prop": "^6.0.0",
"dotenv": "^10.0.0",
"env-paths": "^2.2.0",
Expand Down
5 changes: 2 additions & 3 deletions src/lib/fs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @ts-check
const {
constants,
promises: { access, readFile, rm, stat },
promises: { access, readFile, rm, rmdir, stat },
} = require('fs')
const { version } = require('process')

const del = require('del')
const { gte, parse } = require('semver')

const NODE_VERSION = parse(version)
Expand Down Expand Up @@ -40,7 +39,7 @@ const rmdirRecursiveAsync = async (path) => {
if (gte(NODE_VERSION, '14.14.0')) {
return await rm(path, { force: true, recursive: true })
}
await del(path, { force: true })
await rmdir(path, { recursive: true })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking the behavior. It does not support the force argument as this is only supported in rm which is only avialable from 14.14.0

Which means if it would be used to delete a file it would fail:

https://nodejs.org/api/fs.html#fspromisesrmdirpath-options

Using fsPromises.rmdir() on a file (not a directory) results in the promise being rejected with an ENOENT error on Windows and an ENOTDIR error on POSIX.

To get a behavior similar to the rm -rf Unix command, use fsPromises.rm() with options { recursive: true, force: true }.

As our test coverage is sadly to low I would not do this change as we cannot predict the side effects. I would try to update the minimum node version as fast as possible to 14.14.0 to use rm.

cc @erezrokah @ehmicky

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that fs.promises.rmdir() does not throw ENOENT on missing directories in Node <14.14.0, but I agree with @lukasholzer this might be safer to wait until we drop Node 12. πŸ‘

}

/**
Expand Down