JohnnyMorganz/stylua-action

Semver version specifiers not working as expected

rcloran opened this issue · 1 comments

I was hoping to be able to write something like "version: ^0.17.1" in my workflow config to get behaviour slightly tighter than specifying "latest", but without having to update that config as often. Unfortunately that doesn't work. It looks like the reason is because the input is passed through semver.clean(), which cleans a version number, not a range specifier.

> semver.clean(" 0.17")
null
> semver.clean(" 0.17.1")
'0.17.1'
> semver.clean("=0.17")
null
> semver.clean("=0.17.1")
'0.17.1'
> semver.clean(" ~0.17")
null

From my experimentation it looks like semver.satisfies() is pretty tolerant of input variations (at least as tolerant as .clean()), so I don't think any cleaning is necessary.

The documentation (README.md) says it follows semver syntax, which is what prompted me to think I could use a range specifier. If it's not your intent to allow version ranges, it'd be neat to have the README updated. I'd be happy to take a stab at the change if you want, but I'm not a TypeScript or JavaScript person so this is all pretty new to me.

Also it looks like the changes from 7b40065 didn't make it into the built code in dist/, so the behaviour is still as before that change (which made searching for the error message in the source pretty confusing :))

I think it's fair to properly support semver syntax and remove the clean call. Feel free to send a PR in for it!

Also it looks like the changes from 7b40065 didn't make it into the built code in dist/, so the behaviour is still as before that change

Ah good spot, that's annoying...