forked from github/hubot-scripts
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdibsyCommit.js
More file actions
54 lines (46 loc) · 1.51 KB
/
dibsyCommit.js
File metadata and controls
54 lines (46 loc) · 1.51 KB
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
var child;
var exec = require('child_process').exec;
var colors = require('colors');
var util = require('util');
var version = require('./src/scripts/support/spotVersion');
var theChange = '[no declared change]';
var whatChanged = '??';
var commitMessage;
var commands = require('./src/scripts/support/commitCommands');
var command;
if (version.patches[0]) {
theChange = version.patches[0];
whatChanged = 'patch';
} else if (version.minorChanges[0]) {
theChange = version.minorChanges[0];
whatChanged = 'minor';
} else if (version.majorChanges[0]) {
theChange = version.majorChanges[0];
whatChanged = 'major';
}
commitMessage = util.format('[%s %s] %s update: %s', version.appName, version.version, whatChanged, theChange);
command = [].concat(commands.preCommit, [
'git reset -q HEAD',
'git add --all .',
util.format('git commit -m %s', JSON.stringify(commitMessage)),
util.format('npm version %s', whatChanged),
'git reset HEAD~1',
'git commit -a --amend --no-edit'
], commands.postCommit).join(' && ');
child = exec(command);
child.stdout.pipe(process.stdout);
child.stderr.on('data', function (data) {
(data + '').split('\n').forEach(function (dataLine) {
dataLine = dataLine.replace(/^\s+|\s+$/, '');
if (dataLine) {
console.log(util.format('%s --- %s', 'stderr'.yellow, dataLine));
}
});
});
child.on('error', function (err) {
console.log('ERROR'.red);
console.log(err);
if (err.stack) {
console.log(err.stack);
}
});