-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
updatefile.js
57 lines (51 loc) · 1.64 KB
/
updatefile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
var utils = require('./utils');
module.exports = function(app) {
if (!utils.isValid(app, 'updater-git-tags')) return;
/**
* Update the git tags for a project. This task is an alias for the [git-tags](#git-tags)
* task, to allow running this updater with the following command:
*
* ```sh
* $ update git-tags
* ```
* @name default
* @api public
*/
app.task('default', ['git-tags']);
/**
* Update the git tags for a project. Also aliased as the [default](#default) task.
* This will only find missing git tags if there is a git commit with a version number.
*
* ```sh
* $ update git-tags:git-tags
* ```
* @name git-tags
* @api public
*/
app.task('git-tags', function(cb) {
var opts = {cwd: app.cwd};
utils.parseLog(opts, function(err, commits) {
if (err) return cb(err);
utils.parseTags(opts, function(err, tags) {
if (err) return cb(err);
var missing = commits.filter(function(commit) {
return tags.indexOf(commit.message.trim()) === -1
});
var results = [];
utils.each(missing, function(commit, next) {
console.log(utils.log.timestamp, 'Adding tag', utils.log.cyan(commit.message), 'for commit', utils.log.cyan(commit.commit));
utils.tagCommit(commit, opts, function(err, result) {
if (err) return next(err);
results.push(result);
next();
});
}, function(err) {
if (err) return cb(err);
console.log(utils.log.timestamp, 'Added', utils.log.cyan(results.length), 'missing tags.');
cb();
});
});
});
});
};