vscode-text-power-tools icon indicating copy to clipboard operation
vscode-text-power-tools copied to clipboard

[Feature] remove ^ before package version

Open tjx666 opened this issue 3 years ago • 6 comments

image

tjx666 avatar Jan 23 '22 10:01 tjx666

This seems kind of trivial to do with either search and replace: ": "^": " (Regex flag off) ": "\^": " (Regex flag on) (?<=^\s+"[^"]+": ")\^(?=\d+(\.\d+){0,2}",?$) (Replace with empty string) (Regex flag on, safer but probably unnecessarily so if it's already under version control and you skim the diff before committing. Disclaimer, just threw this together, only lightly tested)

Or multiple cursors.

But maybe you'd like a command that you can trigger on a given line to remove that particular caret?

mrienstra avatar Jan 21 '23 17:01 mrienstra

@mrienstra

😄

Not that I'm not able to do it (after all you can do it pretty easily with basic VS Code editing tools or using some of Text Power Tools own commands), but I'm not 100% sure that that this is the right thing to do. After all there is a lock file for a reason in the repository.

qcz avatar Jan 21 '23 19:01 qcz

My use case is in some package, there some dep is prefix with ^, other are not. So I want to remove all or add all. As for lock file, people who using this command must will pnpm install after call it.

tjx666 avatar Jan 21 '23 21:01 tjx666

Then I will add ^ to the two packages which do not have it (prettier in devDependencies and html-entities in dependencies). Cannot add it to faker though as I use a special fork of it.

qcz avatar Jan 21 '23 22:01 qcz

Then I will add ^ to the two packages which do not have it

@qcz, I think there has been a misunderstanding. I believe @tjx666 was proposing a new user-facing feature, which would make it easy to add or remove ^ from all semver ranges in a given file. Though I may be mistaken.

mrienstra avatar Jan 22 '23 00:01 mrienstra

@mrienstra @qcz you are right. My meaning is not to modify the extension project lock file. I just want this extension provide a new command to remove/add all ^ in package.json

tjx666 avatar Jan 28 '23 10:01 tjx666