Skip to content

add remove --all flag fixes #1048 - #1284

Closed
paolord wants to merge 5 commits into
yarnpkg:masterfrom
paolord:yarn-remove-all
Closed

paolord wants to merge 5 commits into
yarnpkg:masterfrom
paolord:yarn-remove-all

Conversation

@paolord

@paolord paolord commented Oct 20, 2016 •

Copy link
Copy Markdown

Summary

Adds --all flag in yarn remove, only removes packages in dependencies and devDependencies from npm

created a function, checkAllFlag, in remove.js that checks if the flag is set, then populates args with all the packages from npm.

Test plan

included new test in tests/commands/install.js to assert the return value of the checkAllFlag in remove.js

Notes:
npm run build and npm run test is ok on my machine, lints fine.

@samccone

Copy link
Copy Markdown
Member

This seems like a reasonable feature. @yarnpkg/core thoughts?

@bestander

Copy link
Copy Markdown
Member

What is the use case for removing all dependencies?

@paolord

paolord commented Oct 24, 2016

Copy link
Copy Markdown
Author

looking at the issues, users expect a behavior likeyarn remove or yarn remove * to simply remove all dependencies. But it could be dangerous when someone makes an accident, so having an --all flag is a bit better.

@bestander

bestander commented Oct 24, 2016 •

Copy link
Copy Markdown
Member

@paolord, I mean is it a legitimate use case to remove all dependencies?
When would anyone want that?

@paolord

paolord commented Oct 24, 2016

Copy link
Copy Markdown
Author

The best use case really is just expecting yarn to be able to do a remove all, instead of typing each package name after yarn remove. And my PR only removes packages that are found in package.json

@bestander

bestander commented Oct 24, 2016 •

Copy link
Copy Markdown
Member

@paolord, yeah I appreciate that consistency in commands is a good thing to strive for.
Good job on that.
But I would rather keep the code more maintainable by having less code.

In the case where I would want to remove all dependencies I would just rm -rf node_modules yarn.lock package.json and I would almost never want to do that.

Let's close this for now unless there is a need from the community.

@sbarli

sbarli commented Dec 5, 2023

Copy link
Copy Markdown

Know this is an old thread, but this would still be a nice to have --

@bestander re. your question of a use-case:

I am deprecating an app from a monorepo where removing yarn.lock is not an option as it is hoisted at the root of the monorepo and includes dependencies across workspaces. I want to uninstall all dependencies of just one of the workspaces in the monorepo. Seems to do that I have to manually remove them all by name which is both annoying and prone to errors.

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.

4 participants