antfu-collective / ni

💡 Use the right package manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Strip unneeded `--` added by user by mistake when using nr

henrikvilhelmberglund opened this issue · comments

Clear and concise description of the problem

So this is mainly me being silly but I copy pasted the rightmost part of an npm command npm run release -- --release-as 1.1.0 and ran it with nr: nr release -- --release-as 1.0.0 but accidentally copied the -- (npm) part of the command too. (the command itself is from commit-and-tag-version)

This broke the command because this meant that in my case I ran
pnpm run release -- --release-as 1.1.0
instead of
pnpm run release --release-as 1.1.0.

I have no idea if this would break things but if not I think
nr release -- --release-as 1.0.0 and
nr release --release-as 1.0.0
should have the same output because nr already adds the extra -- required in the npm run command.

Suggested solution

If the user added -- by mistake in the nr command, strip them and the whitespace before the next command.
eg.
nr release -- --release-as 1.0.0
would be turned into
nr release --release-as 1.0.0
and the command would automagically work with nr even though it's not 100% correct.

This solution assumes that -- isn't used in nr already though because if it is used those things would stop working.
So any nr -- mynicecommand --witharguments for example wouldn't work, but I have no idea if that's something anyone writes (I'm guessing not).

Alternative

I considered stopping being stupid and copy pasting only the things to the right of -- but realistically I will probably mess up again.

Additional context

No response

Validations

By definition, you don't need -- for nr. Similar to yarn and pnpm@v7. I think forcing users not having the -- would be better to avoid conflicts

It's not really explicitly forced though so it's possible to do stuff like
Code_20_15-56-37XKPhkTsZvK
(by mistake if you're used to the npm way)