-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add class and toString() for dependencies #8
Conversation
function Dependency(package, version) { | ||
this.package = package; | ||
if(version) | ||
this.version = version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't want to separate the >=
? FWIW in theory it can also be ==
or <=
although that's hardly ever used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parser leaves the >=
part in the version. So it already contains e.g. "> 3.0"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am asking if we should separate those or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. I don't think so, I don't see how the >=
by itself is meaingful without the number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if you want to check if a version requirement holds, then you need to separate them every time, so we might already in the parser. Basically inside the parens it is a tiny DSL, so we might as well parse it.
} | ||
|
||
Dependency.prototype.toString = function() { | ||
return this.package + (this.version ? " (" + this.version + ")" : ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we explicitly compare to undefined
? Maybe, IDK.
Maybe the complexity if introducing a type doesn't weigh up to the added complexity right now. I'm closing this for now, maybe revisit later. |
This is a small change that gives dependency instances type
Dependency
such that we can add atoString()
method to the prototype, which restores the original string.This mostly restores backward compatibility with rdesc-parser 2.x :)