diff options
Diffstat (limited to 'node_modules/lodash/tag.js')
-rw-r--r-- | node_modules/lodash/tag.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/node_modules/lodash/tag.js b/node_modules/lodash/tag.js new file mode 100644 index 0000000..acb2eea --- /dev/null +++ b/node_modules/lodash/tag.js @@ -0,0 +1,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); + }); +}); |