-
Notifications
You must be signed in to change notification settings - Fork 27.4k
chore(build): fix version placeholder matching #15016
chore(build): fix version placeholder matching #15016
Conversation
For reference, here are the RegExps that match and replace the version placeholders: lib/grunt/utils.js#L125-L130 |
expect(version.then(validate)).toBe(true); | ||
|
||
function validate(ver) { | ||
return ver.full.indexOf([ver.major, ver.minor, ver.dot].join('.')) === 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.
Why not just ver.full === [ver.major, ver.minor, ver.dot].join('.')
?
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.
That is not always true. E.g. full
can be 1.5.0-rc.2
or 1.5.9-build.4949
or 1.5.9-local+sha.859348c
(this last one is what we actually have in the tests most of the time).
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.
Makes sense. Can you add a comment with that info?
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130
30ba653
to
337b9a9
Compare
df32fc6
to
07e6958
Compare
How about we don't change what you changed here and keep our style but update the regexes so that they accept both string delimiter types? E.g. we'd change: .replace(/"NG_VERSION_FULL"/g, NG_VERSION.full) to: .replace(/(?:'|")NG_VERSION_FULL(?:'|")/g, NG_VERSION.full) etc.? EDIT: or: .replace(/(\\?(?:'|"))NG_VERSION_FULL\1/g, NG_VERSION.full) |
.replace(/(['"])NG_VERSION_MAJOR\1/, NG_VERSION.major) | ||
.replace(/(['"])NG_VERSION_MINOR\1/, NG_VERSION.minor) | ||
.replace(/(['"])NG_VERSION_DOT\1/, NG_VERSION.patch) | ||
.replace(/(['"])NG_VERSION_CDN\1/, NG_VERSION.cdn) |
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 could find this anywhere inside the codebase. It is probably not needed, but left it just in case.
I changed the RegExps to accept both types of quotes. @mgol, PTAL. |
LGTM |
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in #15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes #15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes angular#15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes angular#15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes angular#15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes angular#15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in angular#15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes angular#15016
During the `build` task, the version placeholders will be replaced with the actual values using a RegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes from double to single in #15011, the RegExp was not able to match the placeholders. (For reference, the RegExps that match and replace the version placeholders are in [lib/grunt/utils.js][1].) [1]: https://github.com/angular/angular.js/blob/859348c7f61ff5f93b9f81eb7f46842bd018d8e3/lib/grunt/utils.js#L125-L130 Closes #15016
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information:
During the
build
task, the version placeholders will be replaced with the actual values using aRegExp, which expects the placeholders to be surrounded by double quotes. By replacing the quotes
from double to single in #15011, the RegExp was not able to match the placeholders.
Btw, this has broken
ngMaterial
(since they polyfill$animateCss
based on the value ofangular.version.minor
).