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

Add option to print file being deleted (-V or --verbose) #183

Closed
wants to merge 1 commit into from

Conversation

brunolm
Copy link

@brunolm brunolm commented Oct 24, 2018

Closes #140

rimraf -V <args>
rimraf --verbose <args>

```
rimraf -V <args>
rimraf --verbose <args>
```
@brunolm brunolm changed the title Add option to print file being deleted Add option to print file being deleted (-V or --verbose) Oct 24, 2018
@rashidul0405
Copy link

@isaacs @brunolm Is there any chance of this to get merge?

@isaacs
Copy link
Owner

isaacs commented Apr 12, 2022

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 --verbose is set.

@@ -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')
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Owner

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Owner

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.

Copy link
Contributor

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.

@isaacs
Copy link
Owner

isaacs commented Mar 4, 2023

Implemented somewhat differently on 3b57687, using the filter option added in 4.3.

@isaacs isaacs closed this Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verbose Flag (for CLI)
4 participants