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
|
'use strict';
var _ = require('lodash'),
childProcess = require('child_process'),
execSync = childProcess.execSync,
semver = require('semver'),
spawn = childProcess.spawn;
var branch = 'npm-packages';
var reLine = /^.*$/gm;
var output = execSync('git log ' + branch + ' --pretty=format:"%s | %h"').toString();
var pairs = _.map(output.match(reLine), function(value) {
var pair = _.map(_.trim(value, '"\'').split('|'), _.trim);
pair[0] = _.result(/\d+(?:\.\d+)*/.exec(pair[0]), 0, '');
return pair;
});
pairs = _.filter(pairs, '0');
pairs.sort(function(a, b) {
return semver.gt(a[0], b[0]) ? 1 : (semver.lt(a[0], b[0]) ? -1 : 0);
});
pairs = pairs.map(function(pair) {
var tag = pair[0] + (branch == 'master' ? '' : '-' + branch);
return [
//'git checkout ' + tag + ' && git commit --amend --no-edit --date "`date`"',
'git tag -f -a -m ' + tag + ' "' + tag + '" ' + pair[1],
'git push -f origin ' + tag
];
});
_.each(pairs, function(pair, index) {
_.each(pair, function(command) {
_.delay(function() {
console.log(command)
execSync(command);
}, 1000 * index);
});
});
|