-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Add option to print file being deleted (-V or --verbose) #183
Conversation
``` rimraf -V <args> rimraf --verbose <args> ```
It would be better if the lib wasn't printing. Only the bin should print, the lib should return or stream the files being deleted, and the bin should print them if |
@@ -32,16 +36,23 @@ if (help || args.length === 0) { | |||
log(' -h, --help Display this usage info') | |||
log(' -G, --no-glob Do not expand glob patterns in arguments') | |||
log(' -g, --glob Expand glob patterns in arguments (default)') | |||
log(' -V, --verbose Prints paths being deleted') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rm
command supports -v
(lowercase) instead of -V
. We could support both.
@@ -107,6 +108,9 @@ function rimraf (p, options, cb) { | |||
if (er.code === "ENOENT") er = null | |||
} | |||
|
|||
if (options.verbose) | |||
console.log('deleting', p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, we should use console.info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It's just writing a string to stdout, in this case they're 100% equivalent, I almost always use console.log()
for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of terminal profiles can be (and are) setup to visually highlight different forms of logs. afaik there is also a screen reader for terminal output which can differentiate between log & info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may dismiss this suggestion if it isn't aligned with other code here. I did prefix this with fwiw - not a deal breaker for most.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are literally the same function: https://github.com/nodejs/node/blob/main/lib/internal/console/constructor.js#L682
The only way you could highlight different forms of logs is by patching the global console
object.
They're displayed differently in the browser, but in Node, they're 100% identical, just same function with two different names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, thanks for informing me. I wasn't aware of this.
Implemented somewhat differently on 3b57687, using the |
Closes #140