Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 337b9a9

Browse files
committed
chore(build): fix version placeholder matching
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
1 parent 859348c commit 337b9a9

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

src/AngularPublic.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@
114114
* - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
115115
*/
116116
var version = {
117-
full: '"NG_VERSION_FULL"', // all of these placeholder strings will be replaced by grunt's
118-
major: 'NG_VERSION_MAJOR', // package task
119-
minor: 'NG_VERSION_MINOR',
120-
dot: 'NG_VERSION_DOT',
117+
// These placeholder strings will be replaced by grunt's `build` task.
118+
// They need to be surrounded by double-quotes.
119+
/* eslint-disable quotes */
120+
full: '"NG_VERSION_FULL"',
121+
major: "NG_VERSION_MAJOR",
122+
minor: "NG_VERSION_MINOR",
123+
dot: "NG_VERSION_DOT",
121124
codeName: '"NG_VERSION_CODENAME"'
125+
/* eslint-enable quotes */
122126
};
123127

124128

test/e2e/fixtures/version/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html ng-app>
3+
<body>
4+
<script src="angular.js"></script>
5+
</body>
6+
</html>

test/e2e/tests/version.spec.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
describe('angular.version', function() {
4+
var version;
5+
6+
beforeEach(function() {
7+
loadFixture('version');
8+
version = browser.driver.executeScript('return angular.version');
9+
});
10+
11+
12+
it('should expose the current version as object', function() {
13+
expect(version).toEqual(jasmine.any(Object));
14+
});
15+
16+
it('should contain property `full` (string)', function() {
17+
expect(version.then(get('full'))).toEqual(jasmine.any(String));
18+
});
19+
20+
it('should contain property `major` (number)', function() {
21+
expect(version.then(get('major'))).toEqual(jasmine.any(Number));
22+
});
23+
24+
it('should contain property `minor` (number)', function() {
25+
expect(version.then(get('minor'))).toEqual(jasmine.any(Number));
26+
});
27+
28+
it('should contain property `dot` (number)', function() {
29+
expect(version.then(get('dot'))).toEqual(jasmine.any(Number));
30+
});
31+
32+
it('should contain property `codeName` (string)', function() {
33+
expect(version.then(get('codeName'))).toEqual(jasmine.any(String));
34+
});
35+
36+
it('should have `full` === `"major.minor.dot"`', function() {
37+
expect(version.then(validate)).toBe(true);
38+
39+
function validate(ver) {
40+
return ver.full.indexOf([ver.major, ver.minor, ver.dot].join('.')) === 0;
41+
}
42+
});
43+
44+
45+
// Helpers
46+
function get(prop) {
47+
return function getter(obj) {
48+
return obj[prop];
49+
};
50+
}
51+
});

0 commit comments

Comments
 (0)