Skip to content

Commit e58d0aa

Browse files
committed
bump-version: modernize code
... by using the arrow notation for closures. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent cbe6696 commit e58d0aa

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

bump-version.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,48 @@
77

88
var fs = require('fs');
99

10-
var die = function(err) {
10+
var die = (err) => {
1111
process.stderr.write(err + '\n');
1212
process.exit(1);
1313
};
1414

15-
var updateVersion = function(version, tag, timestamp, url) {
15+
var updateVersion = (version, tag, timestamp, url) => {
1616
var regex = /<div class="version">.*?<\/div>/gm;
1717
var replacement = '<div class="version"><a href="' + url
1818
+ '" title="Version ' + version + ' was published on '
1919
+ timestamp + '">Version ' + version + '</a></div>';
2020
fs.writeFileSync('latest-version.txt', version);
2121
fs.writeFileSync('latest-tag.txt', tag);
22-
fs.readFile('index.html', 'utf8', function (err, data) {
22+
fs.readFile('index.html', 'utf8', (err, data) => {
2323
if (err)
2424
die(err);
2525
data = data.replace(regex, replacement);
2626
fs.writeFileSync('index.html', data);
2727
});
2828
};
2929

30-
var autoUpdate = function() {
31-
Array.prototype.lastElement = function() {
30+
var autoUpdate = () => {
31+
Array.prototype.lastElement = () => {
3232
return this[this.length - 1];
3333
}
3434

35-
Array.prototype.filterRegex = function(regex) {
36-
return this.map(function(value) {
35+
Array.prototype.filterRegex = (regex) => {
36+
return this.map((value) => {
3737
var match = value.match(regex);
3838
if (!match)
3939
return undefined;
4040
return match.lastElement();
41-
}).filter(function (value) {
41+
}).filter((value) => {
4242
return value !== undefined;
4343
});
4444
};
4545

46-
Array.prototype.findFirst = function(regex) {
46+
Array.prototype.findFirst = (regex) => {
4747
var matches = this.filterRegex(regex);
4848
return matches && matches[0];
4949
};
5050

51-
var determineVersion = function(body) {
51+
var determineVersion = (body) => {
5252
var release = JSON.parse(body),
5353
versionRegex = /^v(\d+\.\d+\.\d+(\.\d+)?)\.windows\.(\d+)/,
5454
timeRegex = /^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z$/,
@@ -82,13 +82,13 @@ var autoUpdate = function() {
8282
'headers': {
8383
'User-Agent': 'Git for Windows version updater'
8484
}
85-
}, function(res) {
85+
}, (res) => {
8686
if (res.statusCode != 200)
8787
die(res);
88-
res.on('data', function(data) {
88+
res.on('data', (data) => {
8989
https.body += data.toString();
9090
});
91-
res.on('end', function() {
91+
res.on('end', () => {
9292
var result = determineVersion(https.body);
9393
updateVersion(result[0], result[1], result[2], result[3]);
9494
});

0 commit comments

Comments
 (0)