-
Notifications
You must be signed in to change notification settings - Fork 78
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
rm and stopMany methods have an inconsistent API #223
Comments
We're still below 1.0.0 release, so everything is still subject to changes. @Steveb-p any worries about this? |
This sounds good actually. The function signature looks a lot better the way @johnytiago suggests. Of course I'm worried about a breaking change that this would introduce. Ideally we would have a way of dealing with it, maybe by detecting that we're dealing with an old invocation (maybe by checking if the first argument is an array?) and swapping the arguments as necessary? 🤔 |
A silent upgrade for function calls would be nice. Not sure if we allow |
We could likely come up with a way to make this backwards compatible, but we'd still be introducing a special signature to this two functions only. The inconsistency we'd be introducing is better than the one we had before, though. Regarding versioning and breaking changes, you could postpone removing the old signature for only when you feel like you have enough to go onto |
Maybe we can mark the old signature as deprecated? |
The easiest way of handling it would indeed be adding new functions, instead of trying to shove into the old ones. It would also help with types (or rather, we would not need to do any shenanigans with function declaration, as we're strictly declaring acceptable types currently, and we would probably need to mark lines that perform invalid type checks as ignored). |
Just call them |
I would flag the old ones deprecated anyway so people get aware of it. |
I don't think adding new functions is going to fix the problem either. Plus, I don't think this is a problem enough that people need this feature out to resolve their problems. It's just unpleasant quirk one can easily fix on their end. I'd say the best approach, that respects semantic versioning, is to maintain both signatures temporarily until the later gets deprecated on a major bump. Something like this: function stopMany( options?: IDockerComposeOptions, ...services: string[]): Promise<IDockerComposeResult>;
function stopMany( services: string[], options?: IDockerComposeOptions | undefined): Promise<IDockerComposeResult>;
function stopMany( services: unknown, options: unknown, ...rest) {
if (Array.isArray(services)) {
return execCompose('stop', services, options)
}
const _options = services
const _services = [ options, ...rest ]
return execCompose('stop', _services, _options)
} |
I think this should work. |
The signatures of the
rm
andstopMany
methods is inconsistent with other methods that accept multiple services.For all the other methods that accept multiple services the signature is services first, options second:
Yet, for
rm
andstopMany
the signature is different:I know that changing this signature is likely to result in a breaking change, but would you be willing to accept a PR to fix this?
The text was updated successfully, but these errors were encountered: