-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Library version #1042
Comments
Any example where this kind of detection is necessary? |
We are logging library versions whenever an error occurs on the server side, and sometimes they occur as a result of a package update, which one can easily see then. It's much easier to log things this way when your main library provides the version information. And whenever we debug an Angular app on the client side, we always type in the console: |
I presume |
@petkaantonov probably, but I showed how it is used in Angular.js ;) something for the lazies ;) |
@petkaantonov on the second thought though, no. You should include the version properties, because those make it possible to easily code around new library features, without having to parse the version every time. One would use property |
@petkaantonov also, it would be a good idea to extend every error object thrown by the library with this property This will pay you back, as each error would include the exact version, which people can use automatically when logging issues ;) |
Something like this: function Version() {
this.name = 'false-positives-slayer';
this.major = 3;
this.minor = 3;
this.build = 4;
this.full = this.major + '.' + this.minor + '.' + this.build;
Object.lock(this); // lock the instance fully.
}
// returns the full version as the default console output;
Version.prototype.inspect = function () {
return this.full;
};
// compare to a version string to simplify
// conditional coding, and return:
//
// 0, if equal, -1 if less, 1 if greater.
Version.prototype.compare = function (ver) {
};
var ver = new Version(); // global version instance; |
Yeah I think it's unreasonable to expect all that to be implemented in bluebird. The users who really need more than a string can parse the string easily into such object using the semver module. |
For my purposes, just the full version string would be easily sufficient. But it would be really useful to have a I'm not sure if the Please let me know your preference, and I'll submit a PR. |
@overlookmotel the property should definitely be available from the library's root: var ver = require('bluebird').version; This is how it works in other libraries, like Angular.js: |
@vitaly-t Yeah, I agree. But my question was what's the best way to implement it internally. i.e. how to set the value within bluebird, not access the value from bluebird. |
Considering the following facts about this library:
It is asking to extend the library's root with a
version
object, similar to that of Angular JS:It will help with the diagnostics in libraries built on extensive use of bluebird.
The text was updated successfully, but these errors were encountered: